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

LessThan

Returns a boolean value of true if the item being compared is less than the value of the parameter.

Source

public static bool LessThan<T>(this IComparable<T> comparable, T other)
{
  return comparable.CompareTo(other) < 0;
}

Example

var t1 = new Temperature(273);
var t2 = new Temperature(100);

if (t1.LessThan(t2))
  Console.WriteLine("t1 is less than t2");

Author: Richard Bushnell

Submitted on: 3 mrt 2008

Language: C#

Type: System.IComparable<T>

Views: 2735