本文介绍了枚举类在c ++ -replacement-在c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 查看这些 c ++ 代码: 枚举类标志:int32 { f_unread =(1 f_out =(1 f_上述=(1 $ b b MAX_FIELD =(1 }; c#中的代码是什么? 解决方案 使用有形。看起来没有太大的不同。 [Flags] public enum Flag:int { f_unread =(1 f_out =(1 f_ mentioned =(1≤4), $ b $ c MAX_FIELD =(1 } enum 作为标志操作的位字段,应该添加 FlagsAttribute ,它添加 c>之前 c> c> c> b $ bTake a look at these c++ codes : enum class Flag : int32 { f_unread = (1 << 0), f_out = (1 << 1), f_mentioned = (1 << 4), MAX_FIELD = (1 << 4),};What is the covert of those codes in c#? 解决方案 Using Tangible. Seems like it is not far different.[Flags]public enum Flag : int{ f_unread = (1 << 0), f_out = (1 << 1), f_mentioned = (1 << 4), MAX_FIELD = (1 << 4),}In c#, to use enum as bit field for flags operation, it should be added with FlagsAttribute, which adds [FlagsAttribute] or [Flags] before the enum. 这篇关于枚举类在c ++ -replacement-在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 18:05