How to use StringComparison for strings in C#?
You can use regular expression to match a string search in C#. You also have the option to ignore case.
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
This link might be useful: How to: Search Strings Using Regular Expressions (C# Programming Guide)
I'm not sure if you are using .NET 1.1, but it did not contain the method Contains
. You have to use IndexOf
. .NET 2.0 added the method Contains (per MSDN). With IndexOf, you can use StringComparison.
I don't believe string
has an overload of Contains
taking a StringComparison
. However, you could use IndexOf
which does:
if (body.IndexOf("software", StringComparison.CurrentCultureIgnoreCase) != -1)
String.Contains only take one parameter - your code should be
bodyText.Contains("software");