Extension method something new in 3.5 framework, these are static method on static class.
When this class gets compiled, .NET applies the System.Runtime.CompilerServices.Extension to it,
and when it is in scope, Intellisense can read this information and determine the right method to apply based on the data type
using System.Runtime.CompilerServices;
 | Extension method |
| public static class CustomExtensions
| | 1: {
| | 2: public static int ToInt(this string number)
| | 3: {
| | 4: return Int32.Parse(number);
| | 5: }
| | 6: public static string DoubleToDollars(this double number)
| | 7: {
| | 8: return string.Format("{0:c}", number);
| | 9: }
| | 10: public static string IntToDollars(this int number)
| | 11: {
| | 12: return string.Format("{0:c}", number);
| | 13: }
| | 14: }
| | 15: |
|
Asp.net, Ado.net, .Net Remoting, .Net
Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML