ToString() of an enum.

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Hi

Since an enum member object has a ToString() method, i wonder if it can be
overriden .

johan
 
Probably what Johan is asking in effect is that since System.Enum is an
abstract class it must be derived from, therefore how can I derive from it
so that I can override ToString? The answer is that you can't derive from
it. It's one of those classes which is treated specially by the C# language
(and I would guess by every other .NET language too), like System.Delegate.
Declaring an enum presumably causes the compiler to generate a derived
classs in much the same way that declaring a delegate does.
 
I was thinking more along the lines of the impossibility of adding a method
to an enum derived,override or whatever.

I've always thought that you should at least be able to add static stuff to
an enum - I can't see why not
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top