代码改变世界

枚举 Switch (1)

2009-05-20 17:56  蜡笔小旧  阅读(434)  评论(0编辑  收藏  举报
枚举定义:
            public enum OutLineType { 
                ac ,dc, tc 
            };

   想用switch来选择:

            switch (OutLineType)
            {
                case OutLineType.ac:
                    { AttributeCfgList = fcs.Gig(catId);}
                    break;
                case OutLineType.dc:
                    break;
                case OutLineType.tc:
                    break;
                default:
                    break;
            }
结果报错了,如下:

Error    1    'For.Utility.Confiility.OutLineType' is a 'type' but is used like a 'variable'  

犯了低级错误 OutLineType 是个枚举类型 ,应该用对象做switch 嘿嘿。