Although I don't recommend it, you can easily achieve what you are up to by including your code in public static classes under the namespace System
.
namespace System
{
public static class CaseInsensitiveContains
{
public static bool Contains(this string source, string toCheck, StringComparison comp)
{
return source.IndexOf(toCheck, comp) >= 0;
}
}
}
Without static class, your extension method won't work.
After you put the above in a .cs
file, you can not use String.Contains anywhere since almost all code use System
namespace, which means it is kinda global ;)