String.Content how to do not be case sensitive [duplicate]

1

Hello, I have a string where I want to search if there is a word but not case sensitive.

Example:

string tt2 = "teste amanha de manha";
string pp = "Amanha";
if (tt2.Contains(pp))
{
//Não entra na condição pois na string o amanha tem o "a" em minusculo
}
    
asked by anonymous 15.02.2017 / 12:42

1 answer

2

With Contains method is not possible, but you can have the expected result with IndexOf

string tt2 = "teste amanha de manha";
string pp = "Amanha";
if (tt2.IndexOf(pp, StringComparison.CurrentCultureIgnoreCase) > -1)
{
    //agora ele entra aqui
}
    
15.02.2017 / 12:49