we can’t inherit, enum are by default sealed
Interviews9 answers
Can we inherit enum in C#?
9 Answers
Bidyasagar MishraPosted Aug 4, 2019, 4:29 PM EDT
Enum can not inherit in derived class because by default Enum is sealed.
sushil kumarPosted Mar 7, 2019, 8:12 PM EST
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;
Amit PrakashPosted Jan 1, 2019, 8:55 PM EST
no, we cannot inherit enum
Pravinkumar BirajdarPosted Apr 9, 2018, 9:37 PM EDT
Enum is by default sealed.that why we can inherit enum.
Rakesh SanaboyinaPosted Mar 28, 2018, 10:13 PM EDT
Nope. it is not possible.
Akbar MullaPosted Mar 19, 2018, 8:47 PM EDT
Enums are by default sealed. So, we cant inherit.
Sreekanth ReddyPosted Mar 8, 2018, 6:17 PM EST
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 spec
All enums must derive from System.Enum
Because of the above, all enums are value types and hence sealed
Bharathi RajaPosted Jan 31, 2018, 11:35 PM EST
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
Rathrola Prem KumarPosted Jan 4, 2018, 10:41 PM EST






