using System; using System.Collections.Generic; using System.Linq; namespace AsbCloudInfrastructure { public static class Helper { public static T Max(params T[] items) where T : IComparable { var count = items.Length; if (count < 1) throw new ArgumentException("Count of params must be greater than 1"); var max = items[0]; for (var i = 1; i < count; i++) if (max.CompareTo(items[i]) < 0) max = items[i]; return max; } public static T Min(params T[] items) where T : IComparable { var count = items.Length; if (count < 1) throw new ArgumentException("Count of params must be greater than 1"); var min = items[0]; for (var i = 1; i < count; i++) if (min.CompareTo(items[i]) > 0) min = items[i]; return min; } public static (T min, T max) MinMax(params T[] items) where T : IComparable { var count = items.Length; if (count < 1) throw new ArgumentException("Count of params must be greater than 1"); var min = items[0]; var max = items[0]; for (var i = 1; i < count; i++) if (max.CompareTo(items[i]) < 0) max = items[i]; else if (min.CompareTo(items[i]) > 0) min = items[i]; return (min, max); } } }