foreach(Unit enemy in enemies.OrderByDescending(enemy=>enemy.CurrentHP))
{
Events.UnitDamaged(enemy);
return;
}
如何将多个键值传递给排序?就像是
enemies.OrderByDescending(enemy => enemy.CurrentHP && enemy.MaximumHP)
使用ThenBy
:
enemies.OrderByDescending(enemy => enemy.CurrentHP)
.ThenBy(enemy => enemy.MaximumHP)
enemies.OrderByDescending(enemy => enemy.CurrentHP)
.ThenByDescending(enemy => enemy.MaximumHP)
你可以做
enemies.OrderByDescending(enemy => enemy.CurrentHP)
.ThenByDescending(enemy => enemy.MaximumHP)
试试这个:
enemies.OrderByDescending(enemy => enemy.CurrentHP)
.ThenByDescending(enemy1 => enemy1.MaximumHP)