I don't think Glenn has understood the question properly as you're asking whether the text in the RichTextBox starts with "http://www.debugging.com" and not just whether it's equal to that string:
// if you don't want to include the double quotes
if (richTextBox1.Text.StartsWith("http://www.debugging.com")) { MessageBox.Show("Yes!"); } else { MessageBox.Show("No!"); }
// or, if want to include the double quotes as part of the string
if (richTextBox1.Text.StartsWith("\"http://www.debugging.com\"")) { MessageBox.Show("Yes!"); } else { MessageBox.Show("No!"); }
2 answers
I don't think Glenn has understood the question properly as you're
asking whether the text in the RichTextBox starts with "http://www.debugging.com" and not just whether it's equal to that string:
answered one year ago by:
17279
329
Aha! that would make more sense. Does StartsWith() check the whole string or just the first character? Cool I just had a peak on MSDN for it! Glenn
17279
It checks the whole string and, if I remember correctly, there's an overload which allows you to ignore case amongst other things.
Hmm,
Don't really think I understand/asked the question properly but from the way it is asked
and later on (Change the No! to whatever)
That will do what you asked for, probably not what you meant!
Glenn
answered one year ago by:
329