When declaring an enum, should you force the type to byte for under 256 entities?

后端 未结 7 1624
夕颜
夕颜 2020-12-13 08:51

If you have an enum in your application and you only have a few items, should you force the underlying type to be the smallest possible type?

    enum smalle         


        
7条回答
  •  难免孤独
    2020-12-13 09:30

    The only reason to do this is if you are storing or transmitting this value using a defined protocol that demands the field to be of that size.

提交回复
热议问题