1
Well I have a string where I want to search for 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
}
1
Well I have a string where I want to search for 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
}
2
With the method Contains
is not possible, but one can have the expected result with the method IndexOf
string tt2 = "teste amanha de manha";
string pp = "Amanha";
if (tt2.IndexOf(pp, StringComparison.CurrentCultureIgnoreCase) > -1)
{
//agora ele entra aqui
}
It worked, simple and effective, thank you!
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
you can put the
string
in high or low box withstring.ToUpper()
orstring.ToLower()
– JcSaint
@Jcsaint gambiarra. Works only by coincidence.
– Maniero