Equivalent of Math.Min & Math.Max for Dates?

后端 未结 9 1917
渐次进展
渐次进展 2020-12-13 05:16

What\'s the quickest and easiest way to get the Min (or Max) value between two dates? Is there an equivalent to Math.Min (& Math.Max) for dates?

I want to do som

9条回答
  •  死守一世寂寞
    2020-12-13 06:05

    If you want to call it more like Math.Max, you can do something like this very short expression body:

    public static DateTime Max(params DateTime[] dates) => dates.Max();
    [...]
    var lastUpdatedTime = DateMath.Max(feedItemDateTime, assemblyUpdatedDateTime);
    

提交回复
热议问题