【发布时间】:2014-02-25 14:55:42
【问题描述】:
使用 streamReader 读取文件。
如果该行以1 开头,我想使用该行。
该行将显示为:1,103,1,4454:HH
所以我想在第一个 , 之后但在第二个之前获取号码。所以我需要103 并将其分配给ProductId:
int ProductID;
using (StreamReader sr = new StreamReader(fakeFileToProcess))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
if (line.StartsWith("1,"))
{
//so line will be 1,103,1,44543:HH
//How do I capture the '103'...something like:
//ProductID = line.read between "1," & ","(next comma)
}
if (line.StartsWith("25"))
{
continue;
}
}
}
【问题讨论】:
标签: c# asp.net asp.net-mvc-3 stream inputstream