I have just been playing around making a small networking application using Java when i came across a small and dead simple function which I thought, "hey that is useful," and "oh that would now fit .NET Extension Methods." So straight away lol and got my console up and had a play, and i know it may seem a bit trivial, but it is just a bit tidier than other methods you could use. In all I just like the simple function of the .... function. Working in a case sensitive language, it seems quite relevant to differentiate.
Anyway, enough blabbering, the function is called equalsIgnoreCase(String inValue) and to use in C# simply create a string extension method like so, with an implementation following:
public static class StringExtensions
{
public static bool EqualsIgnoreCase(this string value, string compare)
{
return (compare.ToLower() == value.ToLower());
}
}
Console.WriteLine("QuIt".EqualsIgnoreCase("quit"));
The output is True obviously :-)
Cheers,
Andrew