Last active
February 18, 2017 16:29
-
-
Save CallumWatkins/44e45504db81e1ee9700a2f920bbfa98 to your computer and use it in GitHub Desktop.
Checks whether any given integer is located in the range between two other integers. License: MIT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Checks whether any given integer is located in the range between two other integers. | |
/// </summary> | |
/// <param name="i">The integer to check.</param> | |
/// <param name="min">The minimum value of the range.</param> | |
/// <param name="max">The maximum value of the range.</param> | |
/// <param name="inclusive">Whether or not the minumum and maximum values are included in the range.</param> | |
/// <returns>Boolean</returns> | |
private static bool IsInIntegerRange(this int i, int min, int max, bool inclusive = true) | |
{ | |
if (inclusive) return i >= min && i <= max; | |
return i > min && i < max; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment