C# Class Example.Utilities.Extensions.DecimalExtensions

Show file Open project: feanz/Utilities

Public Methods

Method Description
DigitAtPosition ( this number, int position ) : int

Method that finds a digit at an arbirary position of a decimal. The number. The position of the digit to the right of the decimal (1-n). Digit at position var number = 1.2459m; var digit = number.DigitAtPosition(3); // value is 5 See also http://stackoverflow.com/questions/2923510/what-is-the-best-way-to-find-the-digit-at-n-position-in-a-decimal-number/2924042#2924042.

EnsurePositive ( this number ) : decimal

Ensures that the specified decimal is positive

Private Methods

Method Description
SanitizedDigitAtPosition ( this sanitizedNumber, int validPosition ) : int

Method Details

DigitAtPosition() public static method

Method that finds a digit at an arbirary position of a decimal. The number. The position of the digit to the right of the decimal (1-n). Digit at position var number = 1.2459m; var digit = number.DigitAtPosition(3); // value is 5 See also http://stackoverflow.com/questions/2923510/what-is-the-best-way-to-find-the-digit-at-n-position-in-a-decimal-number/2924042#2924042.
public static DigitAtPosition ( this number, int position ) : int
number this
position int
return int

EnsurePositive() public static method

Ensures that the specified decimal is positive
public static EnsurePositive ( this number ) : decimal
number this The decimal we are ensuring is positive.
return decimal