ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

Contains

a case-insensitive version of String.Contains()

Source

public static bool Contains(this string source, string toCheck, StringComparison comp) {
  return source.IndexOf(toCheck, comp) >= 0;
}

Example

string title = "STRING";
bool contains = title.Contains("string", StringComparison.OrdinalIgnoreCase);

Author: Jared Par

Submitted on: 16 feb 2012

Language: C#

Type: System.String

Views: 3662