ContainsNoCase
Extension for Contains() used extensively, here as `ContainsNoCase` for indexOf() with StringComparison type options: CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, Ordinal, OrdinalIgnoreCase The extension here implements the String.IndexOf Method (String,StringComparison) method: https://msdn.microsoft.com/en-us/library/ms224425(v=vs.110).aspx Allows clean access to this method as `ContainsNoCase(string, StringComparison.TYPE)`
This commit is contained in:
parent
6059ea3dc0
commit
33faec9649
@ -279,6 +279,15 @@ namespace NadekoBot.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Easy use of fast, efficient case-insensitive Contains check with StringComparison Member Types
|
||||
/// CurrentCulture, CurrentCultureIgnoreCase, InvariantCulture, InvariantCultureIgnoreCase, Ordinal, OrdinalIgnoreCase
|
||||
/// </summary>
|
||||
public static bool ContainsNoCase(this string str, string contains, StringComparison compare)
|
||||
{
|
||||
return str.IndexOf(contains, compare) >= 0;
|
||||
}
|
||||
|
||||
public static string TrimTo(this string str, int maxLength, bool hideDots = false)
|
||||
{
|
||||
if (maxLength < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user