我有一个需要分组的列表。在列表中我添加了这个对象:
private class MyObject {
private System.Drawing.Color color;
private string title;
public MyObject(System.Drawing.Color color, string title)
{
this.color = color;
this.title = title;
}
public string Title
{
get { return title; }
set { title = value; }
}
public System.Drawing.Color Color
{
get { return color; }
set { color = value; }
}
}
我将我的列表创建为:
System.Collections.Generic.List<MyObject> mList = new System.Collections.Generic.List<MyObject >();
然后我尝试对内容进行分组:
var groupedList = mList.GroupBy(c => new {c.Title} ).ToList();
那就是我得到错误的时候。有任何想法吗?我怎样才能做到这一点?谢谢!