Enum inheriting from int

前端 未结 9 1249
借酒劲吻你
借酒劲吻你 2020-12-17 08:43

I\'ve found this all over the place in this code:

public enum Blah: int
{
    blah = 0,
    blahblah = 1
}

Why would it need to inherit fro

9条回答
  •  囚心锁ツ
    2020-12-17 09:19

    You do not need to inherit as the base type of an Enum is by default, int.

    http://msdn.microsoft.com/en-us/library/sbbt4032(v=vs.71).aspx

    base-type (Optional)
    The underlying type that specifies the storage allocated for each enumerator. It can be one of the integral types except char. The default is int.
    

提交回复
热议问题