在声明枚举时,您应该强制类型为256以下的实体的字节吗? [英] When declaring an enum, should you force the type to byte for under 256 entities?

查看:98
本文介绍了在声明枚举时,您应该强制类型为256以下的实体的字节吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你的应用程序中有一个枚举,而且只有几个项目,那么你应该强制底层类型是最小的类型吗?

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 smaller : byte
    {
        one,
        two,
        three
    };


推荐答案

不要过早优化,除非您已经使用分析器证明实际上是一个问题。

No. Don't prematurely optimize unless you've proved with a profiler that it's actually a problem.

这篇关于在声明枚举时,您应该强制类型为256以下的实体的字节吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆