Rathrola Prem Kumar
Can we inherit enum in C#?
By Rathrola Prem Kumar in C# on Jan 05 2018
  • Sreekanth Reddy
    Mar, 2018 8

    Enums are by default sealed. So, we cant inherit.

    • 4
  • Rathrola Prem Kumar
    Jan, 2018 5

    No, not possible. Enums cannot inherit from other enums. In fact all enums must actually inherit from System.Enum . C# allows syntax to change the underlying representation of the enum values which looks like inheritance, but in actuality they still inherit from System.enum

    • 3
  • Bharathi Raja
    Feb, 2018 1

    378 down vote accepted This is not possible. Enums cannot inherit from other enums. In fact all enums must actually inherit from System.Enum. C# allows syntax to change the underlying representation of the enum values which looks like inheritance, but in actuality they still inherit from System.enum.See section 8.5.2 of the CLI spec for the full details. Relevant information from the specAll enums must derive from System.Enum Because of the above, all enums are value types and hence sealed

    • 2
  • Pravinkumar Birajdar
    Apr, 2018 10

    no, we cannot inherit enum

    • 1
  • Rakesh Sanaboyina
    Mar, 2018 29

    Enum is by default sealed.that why we can inherit enum.

    • 1
  • Akbar Mulla
    Mar, 2018 20

    Nope. it is not possible.

    • 1
  • Bidyasagar Mishra
    Aug, 2019 4

    we can’t inherit, enum are by default sealed

    • 0
  • sushil kumar
    Mar, 2019 8

    Enum can not inherit in derived class because by default Enum is sealed.

    • 0
  • Amit Prakash
    Jan, 2019 2

    int values to the constants as defined in the existing enum, then you can cast between the enum and the constants, e.g:public enum SomeEnum // this is the existing enum (from WSDL) {A = 1,B = 2,... } public class Base {public const int A = (int)SomeEnum.A;//... } public class Consume : Base {public const int D = 4;public const int E = 5; }// where you have to use the enum, use a cast: SomeEnum e = (SomeEnum)Consume.B;

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS