2007/10/26

MultiLine TextBox (7/9/2009 updated)

In many cases, we want the TextBox accepts multi-line input. If we want to read the whole data, we can just fetch it from TextBox's "Text" property. But how to read the input line by line? Here is how:
string strLineData;
using (StringReader sr = new StringReader())
{
    //fetch line data
    strLineData = sr.ReadLine();

    while (!String.IsNullOrEmpty(strLineData))
    {
        //do something here

        //fetch next line of data
        strLineData = sr.ReadLine();
    }
}

No comments:

Post a Comment