gpt4 book ai didi

c# - 获取具有不同键的重复值的枚举变量的值

转载 作者:行者123 更新时间:2023-12-05 05:23:55 24 4
gpt4 key购买 nike

我有一个 52 张扑克牌的枚举,如下所述,

public enum Card
{
AceClubs = 11,
AceDiamonds = 11,
AceHearts = 11,
AceSpades = 11,
DeuceClubs = 2,
DeuceDiamonds = 2,
DeuceHearts = 2,
DeuceSpades = 2,
EightClubs = 8,
EightDiamonds = 8,
EightHearts = 8,
EightSpades = 8,
FiveClubs = 5,
FiveDiamonds = 5,
FiveHearts = 5,
FiveSpades = 5,
FourClubs = 4,
FourDiamonds = 4,
FourHearts = 4,
FourSpades = 4,
JackClubs = 11,
JackDiamonds = 11,
JackHearts = 11,
JackSpades = 11,
KingClubs = 13,
KingDiamonds = 13,
KingHearts = 13,
KingSpades = 13,
NineClubs = 9,
NineDiamonds = 9,
NineHearts = 9,
NineSpades = 9,
QueenClubs = 12,
QueenDiamonds = 12,
QueenHearts = 12,
QueenSpades = 12,
SevenClubs = 7,
SevenDiamonds = 7,
SevenHearts = 7,
SevenSpades = 7,
SixClubs = 6,
SixDiamonds = 6,
SixHearts = 6,
SixSpades = 6,
TenClubs = 10,
TenDiamonds = 10,
TenHearts = 10,
TenSpades = 10,
ThreeClubs = 3,
ThreeDiamonds = 3,
ThreeHearts = 3,
ThreeSpades = 3
}

我想从枚举创建一个列表

 var cards = Enum.GetValues(typeof(Card));

但它返回列表中的重复键。

enter image description here

最佳答案

使用 Enum.GetNames 而不是 Enum.GetValues

关于c# - 获取具有不同键的重复值的枚举变量的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36623501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com