枚举类在c ++ -replacement-在c# [英] enum class in c++ -replacement- in c#
问题描述
查看这些 c ++ 代码:
枚举类标志:int32 {
f_unread =(1 << 0),
f_out =(1 << 1),
f_上述=(1 <4),
$ b b MAX_FIELD =(1 << 4),
};
c#中的代码是什么?
使用有形。看起来没有太大的不同。
[Flags]
public enum Flag:int
{
f_unread =(1 << 0),
f_out =(1 <1),
f_ mentioned =(1≤4),
$ b $ c MAX_FIELD =(1 <4),
}
Take a look at these c++ codes : What is the covert of those codes in c#? Using Tangible. Seems like it is not far different. In c#, to use 这篇关于枚举类在c ++ -replacement-在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<使用 enum
作为标志操作的位字段,应该添加 FlagsAttribute
,它添加 c>之前 c> c> c> b $ b
enum class Flag : int32 {
f_unread = (1 << 0),
f_out = (1 << 1),
f_mentioned = (1 << 4),
MAX_FIELD = (1 << 4),
};
[Flags]
public enum Flag : int
{
f_unread = (1 << 0),
f_out = (1 << 1),
f_mentioned = (1 << 4),
MAX_FIELD = (1 << 4),
}
enum
as bit field for flags operation, it should be added with FlagsAttribute
, which adds [FlagsAttribute]
or [Flags]
before the enum
.