【发布时间】:2019-09-18 06:16:19
【问题描述】:
我有方法:
private bool MyMethod(PlantType plantType)
{
return plantType.PlantMoveType == PlantMoveType.PlantReady
|| plantType.PlantMoveType == PlantMoveType.PlantRelase
}
我可以把它写成其他方式吗?也许使用 LINQ?
【问题讨论】:
-
目前的方式有什么问题?你想缩短它还是什么?
-
你还有什么意思?我唯一能想到的另一件事是
private bool MyMethod(PlantType plantType) => new [] { PlantMoveType.PlantReady, PlantMoveType.PlantRelase}.Contains(plantType.PlantMoveType); -
例如 LINQ 现在很流行我想知道我在这里如何使用它
标签: c# linq methods refactoring