我目前正在與while循環內聲明一個公共字符串,因爲我想在其他方法如何while循環內聲明一個公共字符串(C#)
字符串使用它(串)問題是「S」
private void CheckLog()
{
bool _found;
while (true)
{
_found = false;
Thread.Sleep(5000);
if (!System.IO.File.Exists("Command.bat")) continue;
using (System.IO.StreamReader sr = System.IO.File.OpenText("Command.bat"))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
if (s.Contains("mp4:production/CATCHUP/"))
{
_found = true;
break;
}
}
}
}
}
你會如何使用它從其他方法?這是一個線程場景嗎? –