2015-10-19 43 views
0

我想从我的枚举列表中获取最小值。我知道我可以:从枚举列表中获取最大值

return Enum.GetValues(typeof(VerloningsPeriodeType)).Cast<VerloningsPeriodeType>().Min(); 

但是,这只是从ENUM,我希望它从我的变种。

喜欢的东西:

public static ENUM_A BepaalMaxVerloningsPeriode(IEnumerable<ENUM_A> periods) 
{ 
    return Enum.GetValues(typeof(ENUM_A)).Cast<ENUM_A>().Min(); 
} 

在哪里放置periods变种?

+0

添加语言签名! –

+0

错过了明显的!打扰一下! – Roelant

+3

替换'Enum.GetValues(typeof(ENUM_A))。演员()''''''' – leppie

回答

5

你可以简单地调用Minperiods本身:

public static ENUM_A BepaalMaxVerloningsPeriode(IEnumerable<ENUM_A> periods) 
{ 
    return periods.Min(); 
} 

这使你的BepaalMaxVerloningsPeriode方法平凡简单。如果您摆脱了自定义方法,并且直接致电Min,那么您的代码几乎肯定会更清晰。