public static bool In <T>(T value, params T[] items) where T : IComparable { ThrowHelper.ArgumentNull((items == null), nameof(items)); ThrowHelper.ArgumentArrayMustNotEmpty((items.Length == 0), nameof(items)); foreach (T item in items) { if (item.CompareTo(value) == 0) { return(true); } } return(false); }
public static T GetMin <T>(params T[] items) where T : IComparable { ThrowHelper.ArgumentNull((items == null), nameof(items)); ThrowHelper.ArgumentArrayMustNotEmpty((items.Length == 0), nameof(items)); T min = items[0]; for (int i = 1; i < items.Length; i++) { if (items[i].CompareTo(min) < 0) { min = items[i]; } } return(min); }