M_WolfCurses_ArrayExtensions_ClosestTo - Maxwolf/WolfCurses GitHub Wiki
NB Method will return int. MaxValue for a sequence containing no elements. Intended to be used to match int value to enumeration but without directly casting it, instead looking for closest match to target value.
Namespace: WolfCurses
Assembly: WolfCurses (in WolfCurses.dll) Version: 1.0.0.0 (1.0.0.0)
C#
public static int ClosestTo(
this IEnumerable<int> collection,
int target
)
- collection
- Type: System.Collections.Generic.IEnumerable(Int32)
Enumerable collection of integers that make up our collection. - target
- Type: System.Int32
Target value which needs to be compared against collection values.
Type: Int32
Int closest matching in collection to target value.
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(Int32). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
http://stackoverflow.com/a/10120982
Supported in: 0.1