Possible Duplicate:
What are your favorite extension methods for C#? (codeplex.com/extensionoverflow)
I've recently started compiling a small library of all the extension methods that I've used in my projects over the last 12 months.
Almost all of them are mundane methods that simply provide shortcuts for my everyday programming tasks. e.g. parsing Integers from String literals.
public static int ToInt(this String s) {
int i;
int.TryParse(s,out i);
return i;
}
or taking a String array and converting it back to a String for printing to Console when I'm debugging code.
public static overrride String ToString(this String[] s) {
StringBuilder sb = new StringBuilder();
foreach(String item in s) {
sb.AppendLine(item);
}
return sb.ToString();
}
I really love these little methods... They have saved me endless amounts of typing over the last 12 months.
So my question for everyone else out there: What are your favorite extension methods that you have written, or use on a regular basis, and for what reason?
Thanks.