welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, February 8, 2012

Read line by line in a string variable using stream reader


Here I share bit of code, i searched recently for my need, it’s about to read data from string variable line by line.

I have a string its contains which number of line with passage..i need to read that string as line by line..
Normally stream reader used to read the lines form the specified path files like txt or any file...But if you pass the string variable directly to the stream reader it will throw an error..For that you need to convert the string into bytes then pass it to stream reader..
Dim reader As New StreamReader(New MemoryStream(Encoding.ASCII.GetBytes(passage.ToString())))

 lnr = reader.ReadLine

I hope u enjoy…


Post a Comment