我有喜歡類:排序列表
class SortNode
{
public Int32 m_valRating = 0;
public SortNode(Int32 valRating)
{
this.m_valRating = valRating;
}
}
和一些列表refSortNodeList
:
List<SortNode> refSortNodeList = new List<SortNode>();
Random refRandom = new Random();
for (int i = 0; i < 100; ++i)
{
refSortNodeList.Add(new SortNode(refRandom.Next(-10, 30)));
}
foreach (var varSortNode in refSortNodeList)
{
Console.WriteLine("SortNode rating is {0}", varSortNode.m_valRating);
}
如何輕鬆地我refSortNodeList
通過m_valRating
場排序?或者,也許我需要使用另一個List類?
謝謝!!!
公共字段是一個壞主意,順便說一句 – 2011-03-28 15:45:20