Reputation: 7203
I know (or so I hear) that writing extension methods for a single stand alone .net class (not an implementation of IEnumerable) is potential code smell. However, for the sake of making the life easier I need to attach a method to the ConfigurationManager class in asp.net. It's a static object so this won't work:
public static List<string> GetSupportedDomains(this ConfigurationManager manager)
{
//the manager needs to be static.
}
So the question is - is it possible to write an extension method for a static class in .net?
Upvotes: 1
Views: 264
Reputation: 58952
No you can not. Extension methods require an instance of a given type, which you cannot get from a static class.
Upvotes: 1