private void button3_Click(object sender, EventArgs e)
{
string searchWithinThis = textBox4.Text;
string searchForThis = textBox5.Text;
int firstCharacter = searchWithinThis.IndexOf(searchForThis);
if (firstCharacter == -1)
{
MessageBox.Show("please enter correct string");
}
else
{
MessageBox.Show("OK");
}
}
If you are using a button to check, this will do it.
Updated code due to the OP's comment;
private void button3_Click(object sender, EventArgs e)
{
string searchWithinThis = textBox1.Text;
int count = searchWithinThis.Split(' ').Length - 1;
bool flag = false;
string[] words = new string[count];
words= searchWithinThis.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (textBox2.Text == words[i])
{
flag = true;
}
}
if (flag)
{
}
else
{
MessageBox.Show("correct the string");
}
}