ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Works on Comparables to check whether the checked value is between two other values. Check relaifciotn.net -> extension methods for more details.


public static bool Between<T>(this T me, T lower, T upper) where T : IComparable<T>
  return me.CompareTo(lower) >= 0 && me.CompareTo(upper) < 0;


if (someNumber.Between(3,7)) // Do stuff...

Author: Frank Quednau

Submitted on: 5 mrt. 2008

Language: C#

Type: System.IComparable<T>

Views: 4675