M_WolfCurses_ArrayExtensions_ClosestTo - Maxwolf/WolfCurses GitHub Wiki

ArrayExtensions.ClosestTo Method

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)

Syntax

C#

public static int ClosestTo(
	this IEnumerable<int> collection,
	int target
)

Parameters

 

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.

Return Value

Type: Int32
Int closest matching in collection to target value.

Usage Note

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).

Remarks

http://stackoverflow.com/a/10120982

Version Information

Wolf Curses

Supported in: 0.1

See Also

Reference

ArrayExtensions Class
WolfCurses Namespace

⚠️ **GitHub.com Fallback** ⚠️