Read line by line in a string RRS feed

  • Question

  • I have a string and I want to read it line by line. Instead of reading character by character and searching for a next-line character, is there any direct class provided by dotnet framework for such task?

    - Sandeep Bhutani
    Monday, April 13, 2009 8:42 AM


  • Hi sandeep , here is the code read the string line by line!

    string Str = "My first Line\r\nMy Second Line\r\nMy third Line";

    using (StringReader reader = new StringReader(Str))
       string line;
          while ((line = reader.ReadLine()) != null)

    for more information click here http://jaiprograms.blogspot.com/2009/04/textbox.html
    • Marked as answer by nobugz Monday, April 13, 2009 10:09 AM
    Monday, April 13, 2009 9:10 AM