Created
January 12, 2017 09:49
-
-
Save lemmit/0e89fdff7ad48cef932cd47df2e7336f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CaseInsensitiveStringExtensions | |
{ | |
public static bool CaseInsensitiveContains(this string source, string toCheck) | |
{ | |
return source.IndexOf(toCheck, StringComparison.OrdinalIgnoreCase) >= 0; | |
} | |
public static bool CaseInsensitiveStartsWith(this string source, string startsWith) | |
{ | |
return source.EndsWith(startsWith, StringComparison.OrdinalIgnoreCase); | |
} | |
public static bool CaseInsensitiveEndsWith(this string source, string endsWith) | |
{ | |
return source.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase); | |
} | |
public static bool CaseInsensitiveEquals(this string source, string str) | |
{ | |
return source.Equals(str, StringComparison.OrdinalIgnoreCase); | |
} | |
public static int CaseInsensitiveCompare(this string source, string str) | |
{ | |
return string.Compare(source, str, StringComparison.OrdinalIgnoreCase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment