The string's IndexOf methods are all case-sensitive.
Fortunately, we have the CompareInfo class in the Globalization namespace, that includes a case-insensitive IndexOf method
using System.Globalization;
string strValue = "C# is a GREAT programming language.";
string strCheck = "great";
CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;
int i = Compare.IndexOf( strValue, strCheck, CompareOptions.IgnoreCase );
Compare.IndexOf here returns the index of the string "great".
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment