oliverbooth / X10D

Extension methods on crack.
https://oliverbooth.github.io/X10D/
MIT License
28 stars 2 forks source link

[Request]: MinMax for built-in numeric types #72

Closed oliverbooth closed 1 year ago

oliverbooth commented 1 year ago

Type to extend

System.Collection.Generic.Enumerable

Signature

(T Minimum, T Maximum) MinMax<T>()

Summary

Returns the minimum and maximum values contained in the current collection of ____.

Parameters

n/a

Benefits

Drawbacks

Implementation Example

var minValue = T.MaxValue;
var maxValue = T.MinValue;

foreach (T item in source)
{
    if (item < minValue)
    {
        minValue = item;
    }

    if (item > maxValue)
    {
        maxValue = item;
    }
}

return (minValue, maxValue)

Code of Conduct