Extension methods on a static object
Posted
by
Max Malygin
on Stack Overflow
See other posts from Stack Overflow
or by Max Malygin
Published on 2010-12-27T15:47:31Z
Indexed on
2010/12/27
15:54 UTC
Read the original article
Hit count: 163
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?
© Stack Overflow or respective owner