你好我正在嘗試在C#中創建一個按鈕,如果你按下它。它應該從附加的txt文件的IP地址產生一個消息框。但是我收到了我無法解決的錯誤。我想我有我的返回類型混合起來,我一直有麻煩,這是代碼。對返回類型感到困惑
private String getIPAddress()
{
String x;
using (TextReader configfile = File.OpenText("PC104Configs.txt"))
while (configfile.Peek() > -1) // If therre are no more characters in this line
{
x = configfile.ReadLine();
if (x.Length == 0)
{
// This is a blank line
continue;
}
if (x.Substring(0, 1) == ";")
{
// This is a comment line
continue;
}
if (x == trueIP)
{
// This is the real deal
testPort = configfile.ReadLine();
testIP = trueIP;
return MessageBox.Show(trueIP);
}
} // End of 'while' there are more characters loop
UnitToTest.Text = "";
MessageBox.Show("Specified Configuration Not Found!");
return (false);
}
private void btnSendConfig_Click(object sender, EventArgs e)
{
getIPAddress();
}
」但是我收到了我無法解決的錯誤。「你能顯示錯誤信息嗎? – 2012-07-26 01:16:10
歡迎來到[so],我們一直期待着你。你爲什麼需要'configfile.ReadLine();'兩次,trueIP聲明在哪裏? – 2012-07-26 01:19:17