Possible Duplicate:
incorrectly checks the response c#
I have a code:
Match match = regex.Match(responseFromServer);
if (match.Success)
{
var input = responseFromServer;
var split = input.Split(':');
var final = split[3];
ProcessStartInfo mcStartInfo = new Shitocode;
Process.Start(mcStartInfo);
this.Close();
}
else if (responseFromServer == " Bad Login")
{
MessageBox.Show("Uncorrect login/password!");
}
else if (responseFromServer == " Old version")
{
MessageBox.Show("Launcher is old!");
}
Why there is no message box showing in the last two inspections?
I have tried to do things differently:
if (match.Success)
{
var input = responseFromServer;
var split = input.Split(':');
var final = split[3];
ProcessStartInfo mcStartInfo = new Shitocode;
Process.Start(mcStartInfo);
this.Close();
}
else if (responseFromServer.Equals("Bad Login"))
{
MessageBox.Show("Uncorrect login/password!");
}
else if (responseFromServer.Equals("Old Version"))
{
MessageBox.Show("Launcher is old!");
}
I enter the wrong password, but does not open the messagebox
Probably your responseFromServer does not match the values you are checking (Bad Login, and Old Version).
Try to add another else at the end of the if sequence and look what you’ve got.
EDIT after comment
If you do not the exact message, but you know that it has to contain some exact string, you could change the two
responseFromServer.Equals()toresponseFromServer.Contains()