本文整理汇总了C#中System.IO.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.OrderBy方法的具体用法?C# System.IO.OrderBy怎么用?C# System.IO.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO
的用法示例。
在下文中一共展示了System.IO.OrderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortObjectCanBeSortedByMonsterIdAndMark
public void SortObjectCanBeSortedByMonsterIdAndMark()
{
var s = new[]{
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 2 },
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 1 },
new SortedBoxObject { Mark = 1, MonsterId = 3 },
new SortedBoxObject { Mark = 1, MonsterId = 2 },
new SortedBoxObject { Mark = 2, MonsterId = 3 },
new SortedBoxObject { Mark = 1, MonsterId = 1 },
new SortedBoxObject { Mark = 0, MonsterId = 0 }
};
var r = s.OrderBy( o=> o ).ToArray();
Assert.AreSame( s[6], r[0] );
Assert.AreSame( s[7], r[1] );
Assert.AreSame( s[5], r[2] );
Assert.AreSame( s[4], r[3] );
Assert.AreSame( s[8], r[4] );
Assert.AreSame( s[3], r[5] );
Assert.AreSame( s[1], r[6] );
Assert.AreSame( s[0], r[7] );
Assert.AreSame( s[2], r[8] );
}
示例2: SortObjectCanBeSortedByMonsterId
public void SortObjectCanBeSortedByMonsterId()
{
var s = new[]{
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 2 },
new SortedBoxObject { Mark = 0, MonsterId = 3 },
new SortedBoxObject { Mark = 0, MonsterId = 1 }
};
var r = s.OrderBy( o=> o ).ToArray();
Assert.AreSame( s[3], r[0] );
Assert.AreSame( s[1], r[1] );
Assert.AreSame( s[0], r[2] );
Assert.AreSame( s[2], r[3] );
Assert.AreNotSame( s[3], r[1] );
}