在C#中获取和设置枚举

use*_*227 0 c# enums get set

当我尝试下面的代码时,我收到一条消息"当前上下文中不存在名称C".我在这里错过了什么?我希望字典中的位置部分表现得像其他变量一样,但我一直在使用枚举时遇到问题.谢谢!

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 });

        }
Run Code Online (Sandbox Code Playgroud)

lc.*_*lc. 6

你错过了枚举的名字pos.

position = pos.C;
//         ^^^^
Run Code Online (Sandbox Code Playgroud)