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
@ -278,6 +278,15 @@ namespace NadekoBot.Extensions
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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)
|
public static string TrimTo(this string str, int maxLength, bool hideDots = false)
|
||||||
{
|
{
|
||||||
@ -436,4 +445,4 @@ namespace NadekoBot.Extensions
|
|||||||
: usr.AvatarUrl;
|
: usr.AvatarUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user