August 5, 2009

Extensions Methods with .NET 2.0

I've often wished I could have my extension methods on .NET 2.0 since that's what I build with most of the time. Now with some help from Nate Kohari and Scott Hanselman I can. Just add the following to your .NET 2.0 project.
namespace System.Runtime.CompilerServices
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false,
Inherited = false)]
public class ExtensionAttribute : Attribute
Since the project is still compiled with the 3.x or 4.x compiler the extensions are properly added.

No comments:

Post a Comment