Click or drag to resize

ExtensionMethodsRoundToNearest Method (Single, Int32)

Rounds a number where you can specify the precision of the rounding

Namespace:  DustProductions.Core
Assembly:  DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static float RoundToNearest(
	this float numToRound,
	int roundTo
)

Parameters

numToRound
Type: SystemSingle
The number being rounded
roundTo
Type: SystemInt32
The precision of the rounding (e.g. Passing in 5 will round to the nearest number divisible by 5)

Return Value

Type: Single
A float that has been rounded to the nearest number divisible by roundTo

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Single. 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).
See Also