天气非常炎热,所以我的大脑没有工作那么好。 与 LINQ 相比, 什么是最好的排序方法? 注意根据“ C” 进行排序, 但应用到“ M ” 。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Compare
{
public class M
{
public IList<C> Columns = new List<C>();
}
public class C
{
public bool SortByMe { get; set; }
public string Guid { get; set; }
}
class Program
{
static void Main(string[] args)
{
IList<M> list = new List<M>();
M one = new M();
one.Columns.Add(new C()
{
SortByMe = true,
Guid = "5"
});
one.Columns.Add(new C()
{
});
one.Columns.Add(new C()
{
});
M two = new M();
two.Columns.Add(new C()
{
});
two.Columns.Add(new C()
{
SortByMe = true,
Guid = "2"
});
two.Columns.Add(new C()
{
});
M three = new M();
three.Columns.Add(new C()
{
});
three.Columns.Add(new C()
{
SortByMe = true,
Guid = "100"
});
three.Columns.Add(new C()
{
});
list.Add(one);
list.Add(two);
list.Add(three);
//Then sort the M by the occurrence of a C with SortByMe true.
}
}
}