안녕하세요, C#으로 버튼을 만들려고합니다. IP 주소가 첨부 된 txt 파일의 메시지 상자를 생성해야합니다. 그러나 내가 수정할 수없는 오류가 발생하고 있습니다. 나는 내 리턴 타입이 섞여 있다고 생각한다. 그리고 나는 항상 코드에 문제가있다.반환 유형에 혼란스러워하기
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();
}
"그러나 수정할 수없는 오류가 발생했습니다." 오류 메시지를 표시 할 수 있습니까? –
[so]에 오신 것을 환영합니다. 왜'configfile.ReadLine();'을 두 번해야하고, true가 선언 된 곳은 어디입니까? –