简体   繁体   中英

How to use type name in enum

How can I do the following?

public enum SlideSize { full, half, short };

Do I have to do something like this?

public enum SlideSize { full, half, [Description("short")] shortSlide };

Unfortunately my workaround behaves like a string.

The @ symbol can be used to tell the compiler that you want to use a keyword as a variable name.

public enum SlideSize { full, half, @short };

Though I would recommend following John Wu's answer.

Enums should be in Pascal case .

public enum SlideSize { Full, Half, Short };

If you follow that convention, the problem goes away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM