Why we can't have “char” enum types

前端 未结 9 991
不知归路
不知归路 2020-12-06 03:50

I want to know why we can\'t have \"char\" as underlying enum type. As we have byte,sbyte,int,uint,long,ulong,short,ushort as underlying enum type. Second what is the defau

9条回答
  •  失恋的感觉
    2020-12-06 04:43

    See ECMA standard 335, Common Language Infrastructure (CLI), in Ecma International. The CLI allows the underlying type to be char or bool but C# and VB.Net don't allow it. For what it is worth, C++/CLI does allow System::Char as the underlying type.

    I presume that C# and VB.Net don't allow char and bool as the underlying type for syntactical reasons only.

提交回复
热议问题