[标志]枚举:长仅支持32位? [英] [Flags] enum: long does only support 32 bits?
问题描述
我有一个带标记的枚举,其中包含32个以上的应组合选项.
I have a flagged enum with more than 32 options that should be combineable.
[标志]枚举ABC:长{A = 1<< 0,/*...*/B = 1<< 31,C = 1<< 32};
static void Main(string [] args)
{
Console.WriteLine("B | C = {0}",ABC.B | ABC.C);
}
[Flags] enum ABC : long { A = 1 << 0, /*...*/ B = 1 << 31, C = 1 << 32 };
static void Main(string[] args)
{
Console.WriteLine("B | C = {0}", ABC.B | ABC.C);
}
输出:" B | C = A,B".
Output: "B | C = A, B".
也:Enum.GetValues(typeof(F1))返回[1,1 << 31,1]
Also: Enum.GetValues(typeof(F1)) returns [1, 1<<31, 1]
但是(按预期):Enum.GetNames(typeof(F1))= ["C","A","B"]
But (as expected): Enum.GetNames(typeof(F1)) = ["C","A","B"]
是错误还是功能?
推荐答案
1L<< 32
1L << 32
这篇关于[标志]枚举:长仅支持32位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!