开发平台(Platform):
(Ex: Win10, Linux, ...)
win10
编译器(Ex: GCC, clang, VC++...)+目标环境
(跟开发平台不同的话需列出)
viusal studio 内的c#
问题(Question):
换档案读取后就无法正常运作
喂入的资料(Input):
1.txt内容
1234567where is my friend? sorry 你没朋友
2.txt内容
7654321where do you live sorry i cannot tell you
预期的正确结果(Expected Output):
1.txt 1234567where is my friend
2.txt 7654321where do you live
错误结果(Wrong Output):
1.txt结果是成功的
2.txt结果 7654321 i tell you
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
using (StreamReader sr = newStreamReader(@"C:\Users\Administrator\Desktop.1.tx
t"))
while (sr.Peek() != -1)
{ string line = sr.ReadLine();
foreach (var ch in line)
{ string[] words = line.Split();
string together = string.Join(" ", words); string x = sr.ReadLine();
if (x == "sorry")
{ break;
}
Console.WriteLine(x);
}
}
Console.Read();
补充说明(Supplement):
想请问版上的高手们应该如何修改呢?谢谢