Is the string-method .Contains case-sensitive in .Net?
For example:
string str1 = "tEst";
string str2 = "Te";
Boolean bool = str1.Contains(str2);
Is the string-method .Contains case-sensitive in .Net?
For example:
string str1 = "tEst";
string str2 = "Te";
Boolean bool = str1.Contains(str2);
From Microsoft's official documentation:
Remarks This method performs an ordinal (case-sensitive and culture-insensitive) comparison.
read it for more..
Yes. By default, string comparisons are always case sensitive in the framework. The recommended way is to get case insensitivity is to use a StringComparison or a stringComparer to specify case insensitivity.
Versions of .Net older than .Net core 2.1 lack a .Contains
overload that takes such an argument. A workaround is to use .IndexOf
and check that it returns a index >= 0
, since that can take a StringComparison argument.