String Problems

G

Guest

I'm having a problem comparing strings. In the following code I never get the message box to pop up. The text box does print "KEY" though. I've triend receive == "KEY" and receive.Equal("KEY") but neither works.

public void WaitForPackets()
{
while(true)
{
string receive;
byte[] data = client.Receive(ref receivePoint);
receive = System.Text.Encoding.ASCII.GetString(data) + "\r\n";
textBox1.Text += receive;

if(receive.Equals("KEY"))
{
MessageBox.Show("Yes");
}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top