.NET Linq获取一个集合中的一个或多个属性,赋值到新的类对象

//得到自定义的list

var list = schoolGradeClassModelList.Select(x => new DropDownListData() { DataTextField = x.gradename, DataValueField = x.grade }).ToList();

//新的类

public class DropDownListData
        {
            /// <summary>
            /// 绑定的数据名称
            /// </summary>
            public string DataTextField { get; set; }
            /// <summary>
            /// 绑定的数据值
            /// </summary>
            public object DataValueField { get; set; }
            public DropDownListData() { }
            public DropDownListData(string dataTexField, string dataValueField)
            {
                this.DataTextField = dataTexField;
                this.DataValueField = dataValueField;
            }
        }

上一篇:5G时代必备 音视频WebRTC实时互动直播技术入门与实战


下一篇:seajs hello world