[英]Getting and Setting an Enum in C#
When I try the code below, I get a message that "the name C does not exist in the current context." 当我尝试下面的代码时,我收到一条消息“名称C在当前上下文中不存在”。 What am I missing here?
我在这里想念什么? I would like the position part in the dictionary to behave just like the other variables, but I've been having trouble using the enum.
我希望字典中的位置部分的行为与其他变量一样,但是我在使用枚举时遇到了麻烦。 Thanks!
谢谢!
class stats
{
enum pos { fiB, seB, SS, thB, LF, CF, RF, C, DH, SP, RP };
public double age {get; set;}
public pos position{get; set;}
public double ovalue{get; set;}
public double dvalue{get; set;}
}
public partial class playerdictionary:stats
{
public playerdictionary()
{
var dict = new Dictionary<string, stats>();
dict.Add("AG", new stats { age = 24, position=C, ovalue = 0, dvalue = 4.2 });
}
You're missing the enum's name pos
. 您缺少枚举的名称
pos
。
position = pos.C;
// ^^^^
它应显示为:
position = pos.C
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.