출처 : http://stackoverflow.com/questions/1500194/c-looping-through-lines-of-multiline-string#1500257




아래와 같이 함수를 만들고..


public static List<string> LineReader(this string input)

{

    List<string> rtn = new List<string>();

    using (StringReader reader = new StringReader(input))

    {

        string line;

        while ((line = reader.ReadLine()) != null)

        {

            rtn.Add(line);

        }

    }

    return rtn;

}

 

 

 

아래와 같이 사용한다.

 

foreach (string line in stringData.LineReader())

{

    // Do something with the line

}

Posted by motolies
,