本文介绍了获取错误“提供的类型必须是枚举。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! GeneralSelectServiceClient objservice = new GeneralSelectServiceClient(); IEnumerable< clist> objApproverlist = objservice.GetCList(txtbox.Text); var result = 来自 CList cu in objApproverlist 选择 new {CCode =( int )Enum.Parse( typeof (CList),cu.ToString()),CDescription = cu.ToString()} ; // 此行 var tempValue = new {CCode = 0 ,CDescription = - 选择 - }; var list = result.ToList(); // 创建可变列表 list.Insert( 0 ,tempValue); cbCurrency.DisplayMember = CDescription; cbCurrency.ValueMember = CCode cbCurrency.DataSource = objApproverlist.ToList (); 解决方案 GeneralSelectServiceClient objservice = new GeneralSelectServiceClient(); IEnumerable<clist> objApproverlist = objservice.GetCList(txtbox.Text); var result = from CList cu in objApproverlist select new { CCode = (int)Enum.Parse(typeof(CList), cu.ToString()), CDescription = cu.ToString() }; //this line var tempValue = new { CCode = 0, CDescription = "-- Select --" }; var list = result.ToList(); // Create mutable list list.Insert(0, tempValue); cbCurrency.DisplayMember = "CDescription"; cbCurrency.ValueMember = "CCode" cbCurrency.DataSource = objApproverlist.ToList(); 解决方案 这篇关于获取错误“提供的类型必须是枚举。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 20:39