Let's make a list of answers where you post your excellent and favorite extension methods.
The requirement is that the full code must be posted and a example and an explanation on how to use it.
Based on the high interest in this topic I have setup an Open Source Project called extensionoverflow on Codeplex.
Please mark your answers with an acceptance to put the code in the Codeplex project.
Please post the full sourcecode and not a link.
Codeplex News:
24.08.2010 The Codeplex page is now here: http://extensionoverflow.codeplex.com/
11.11.2008 XmlSerialize / XmlDeserialize is now Implemented and Unit Tested.
11.11.2008 There is still room for more developers. ;-) Join NOW!
11.11.2008 Third contributer joined ExtensionOverflow, welcome to BKristensen
11.11.2008 FormatWith is now Implemented and Unit Tested.
09.11.2008 Second contributer joined ExtensionOverflow. welcome to chakrit.
09.11.2008 We need more developers. ;-)
09.11.2008 ThrowIfArgumentIsNull in now Implemented and Unit Tested on Codeplex.
Allows me to replace:
With:
I find this one pretty useful:
You may use it on CodePlex.
Here's a to-and-from for Roman numerals. Not often used, but could be handy. Usage:
The source:
string.Format shortcut:
Example:
For quick copy-and-paste go here.
Don't you find it more natural to type
"some string".F("param")
instead ofstring.Format("some string", "param")
?For a more readable name, try one of these suggestion:
..
A convenient way to deal with sizes:
Turn this:
... into this:
... using this extension method:
More ADO.NET extension methods: DbExtensions