Skip to content

Instantly share code, notes, and snippets.

@andylshort
Created February 22, 2018 21:42
Show Gist options
  • Save andylshort/c728fc9c6b6085dc5dcd9aa3f4d9b314 to your computer and use it in GitHub Desktop.
Save andylshort/c728fc9c6b6085dc5dcd9aa3f4d9b314 to your computer and use it in GitHub Desktop.
Range struct to handle max and min and adapts
struct Range
{
private int _min;
public int Min
{
get { return _min; }
set
{
_min = value > _max ? _max : value;
}
}
private int _max;
public int Max
{
get { return _max; }
set
{
_max = value < _min ? _min : value;
}
}
public Range(int min, int max)
{
_min = min;
_max = max;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment