enum inheritance 
Author Message
 enum inheritance

Hi

Is it possible to declare an enum type that inherits from an other one.
For instance, something like this :

enum Color { red, blue, green}
and
enum NewColor : Color {yellow, grey, purple}

so that NewColor also contains red, blue and green.

Thanks in advance.
Lionel Plessis



Sun, 31 Oct 2004 18:40:03 GMT  
 enum inheritance
Not, as far as I know. What you can do, that define all of
values as static public members in some class. This way
you can achieve inheritance..


Sun, 31 Oct 2004 18:53:15 GMT  
 enum inheritance
Hello Lionel,

The enum can not be defined as inherit from another one. It is defined in
C# Language Specification 14.2

"The modifiers of an enum declaration have the same meaning as those of a
class declaration (Section 10.1.1). Note, however, that the abstract and
sealed modifiers are not permitted in an enum declaration. Enums cannot be
abstract and do not permit derivation."

You may get more information about it from the link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cssp...

I hope this information is helpful.

Best regards,

Lion Shi, MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    Subject: enum inheritance
    Date: Wed, 15 May 2002 12:40:03 +0200
    Lines: 16
    X-Priority: 3
    X-MSMail-Priority: Normal
    X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

    Newsgroups: microsoft.public.dotnet.languages.csharp
    NNTP-Posting-Host: ngc84.univ-mulhouse.fr 193.50.153.84
    Path: cpmsftngxa08!tkmsftngp01!tkmsftngp05
    Xref: cpmsftngxa08 microsoft.public.dotnet.languages.csharp:60959
    X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

    Hi

    Is it possible to declare an enum type that inherits from an other one.
    For instance, something like this :

    enum Color { red, blue, green}
    and
    enum NewColor : Color {yellow, grey, purple}

    so that NewColor also contains red, blue and green.

    Thanks in advance.
    Lionel Plessis



Tue, 02 Nov 2004 00:16:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. single inheritance and function inheritance

2. typedef enum as subset of another enum

3. enum - enum ?

4. enum - enum ?

5. Name hiding through inheritance

6. Typed Datasets Inheritance

7. Bug report in C++ 2003: Failure to compile inheritance from non-public superclass

8. visual inheritance in VC++ .NET 2003

9. VC++ bug with ambiguous operators due to inheritance?

10. Inheritance typeid question

11. Inheritance Question

12. Inheritance

 

 
Powered by phpBB® Forum Software