Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IComparable<T> Max and Min #23

Closed
oliverbooth opened this issue Jan 17, 2021 · 1 comment
Closed

IComparable<T> Max and Min #23

oliverbooth opened this issue Jan 17, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@oliverbooth
Copy link
Owner

Type

System.IComparable<T>

Extension method signature

T Max<T>(T);
T Min<T>(T);

Parameters

Parameter Type Description
other T The value to compare against.

Description
Returns the maximum/minimum of two values.

Benefits
Math.Min() and Math.Max only support primitives and do not support generic comparable types.

Drawbacks
None considered (at this time)

(Optional) Implementation example

{
    return value.GreaterThan(other) ? value : other;
    // or
    return value.LessThan(other) ? value : other;
}
@oliverbooth oliverbooth added the enhancement New feature or request label Jan 17, 2021
@oliverbooth oliverbooth added this to the 3.0.0 milestone Jan 17, 2021
@oliverbooth oliverbooth self-assigned this Jan 17, 2021
oliverbooth added a commit that referenced this issue Jan 17, 2021
@oliverbooth
Copy link
Owner Author

Implemented with ac8aead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant