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

IsInRange

Finds if the int is the specified range

Source

public static bool IsInRange(this int target, int start, int end) {

return target >= start && target <= end;

}

Example

int foo = 4;
Console.WriteLine(foo.IsInRange(2,6)); // output 'True'

Author: Marwan Aouida

Submitted on: 15 okt 2010

Language: C#

Type: System.Int32

Views: 7157