CrB*_*uno 0 c# string stringreader
我有一个大字符串要读,它总是不同的,但一个字总是一样的.这个词是MESSAGE,所以如果我的字符串阅读器遇到这个词,它必须将整个字符串写入光盘.我做了一些代码,但它没有工作,if段永远不会触发,这里有什么问题?
string aLine;
StringReader strRead = new StringReader(str);
aLine = strRead.ReadLine();
if (aLine == "MESSAGE")
{
//Write the whole file on disc
}
Run Code Online (Sandbox Code Playgroud)
你可以使用Contains,
if(aLine.Contains("MESSAGE")
{
}
Run Code Online (Sandbox Code Playgroud)