Possible duplicate:
Can you create a Static / Shared extension method?
Extension methods are great! Forgive my ignorance, but so far I have found that you can extend the class to allow methods in your instances, but not the class itself.
Here is what I am trying to do.
I have an enumeration like this:
enum ViewType
{
Front_View,
Back_View
}
And I already created an extension method ToDescription()to display a convenient textual representation of the view type, for example:
ViewType thisview = ViewType.Front_View;
string thisviewtext = thisview.ToDescription();
But later in the code, I want to analyze this translation back to a type, like this potential code, assuming that I can extend the enumeration type itself:
ViewType newview = ViewType.ParseFromDescription("Front View");
How to implement this extension method ParseFromDescription(string)(if possible)?