110,545
社区成员
发帖
与我相关
我的任务
分享
StringBuilder stringToRead = new StringBuilder();
stringToRead.AppendLine("Characters in 1st line to read");
stringToRead.AppendLine("and 2nd line");
stringToRead.AppendLine("and the end");
List<string> strList=new List<string>();
using (StringReader reader = new StringReader(stringToRead.ToString()))
{
while(reader.peek>-1){
strList.add(reader.ReadLine);
}
}
这样把没行都放在了strList里面 你要读取第一行就是strList[0] 第二行就是strList[1]...
具体请参考MSDN 详细资料
http://msdn.microsoft.com/zh-cn/library/system.io.stringreader.aspx