Can anyone help me in writing a piece of code in C# Winforms, which can give me a boolean value, that whether a piece of string contains a few words.
For example, If I want to check whether string test only string exists in string "Data is provided to test only string".
I have written following piece of code, but it alwys gives me true, whether string contains the words or nor.
private bool ContainsText(string input)
{
for (int i = 0; i < input.Length; i++)
{
if (((int)input[i] >= 65 && (int)input[i] <= 90) || ((int)input[i] >= 97 && (int)input[i] <= 177))
return true;
}
return false;
}
When I call the following line, I always get true, which is not correct
MessageBox.Show(ContainsText("test only string").ToString());