C# Class Utilities.Extensions.NumberExtensions

Afficher le fichier Open project: feanz/Utilities

Méthodes publiques

Méthode Description
Days ( this num ) : System.TimeSpan

Converts the number to days as a TimeSpan.

DaysAgo ( this days ) : System.DateTime

Returns a date in the past by given number of days.

DaysFromNow ( this days ) : System.DateTime

Returns a date in the future by days.

EnsurePositive ( this number ) : float

Ensures that the specified float is positive

EnsurePositive ( this number ) : int

Ensures that the specified integer is positive

ForceLength ( this number, int length ) : string

Convert integer to string with a minimum length padding with "0" if int is to short.

Hours ( this num ) : System.TimeSpan

Converts the number to hours as a TimeSpan

HoursAgo ( this hours ) : System.DateTime

Returns a date in the past by hours.

HoursFromNow ( this hours ) : System.DateTime

Returns a date in the future by hours.

IsEven ( this value ) : bool

Returns true if number is even

IsOdd ( this value ) : bool

Returns true if number is odd

Minutes ( this num ) : System.TimeSpan

Converts the number of minutes as a TimeSpan

MinutesAgo ( this minutes ) : System.DateTime

Returns a date in the past by minutes

MinutesFromNow ( this minutes ) : System.DateTime

Returns a date in the future by minutes.

Seconds ( this num ) : System.TimeSpan

Converts the number to seconds as a TimeSpan

SecondsAgo ( this seconds ) : System.DateTime

Gets a date in the past according to seconds

SecondsFromNow ( this seconds ) : System.DateTime

Gets a date in the future by seconds.

Time ( this num ) : System.TimeSpan

Converts the number to a TimeSpan.

Time ( this num, bool convertSingleDigitsToHours ) : System.TimeSpan

Converts the military time to a timespan.

ToBinary ( this number ) : string

Returns a binary string representation of the number.

ToHex ( this number ) : string

Returns a hexadecimal string representation of the number.

ToHexChar ( this nibble ) : int

Convert an nibble value(4 bit) integer to its corresponding hex value

ToStringCurrentCulture ( this instance ) : string

Returns a string representation using the Current culture

ToStringInvariantCulture ( this instance ) : string

Returns a string representation using an invariant culture

Method Details

Days() public static méthode

Converts the number to days as a TimeSpan.
public static Days ( this num ) : System.TimeSpan
num this Number representing days
Résultat System.TimeSpan

DaysAgo() public static méthode

Returns a date in the past by given number of days.
public static DaysAgo ( this days ) : System.DateTime
days this The days.
Résultat System.DateTime

DaysFromNow() public static méthode

Returns a date in the future by days.
public static DaysFromNow ( this days ) : System.DateTime
days this The days.
Résultat System.DateTime

EnsurePositive() public static méthode

Ensures that the specified float is positive
public static EnsurePositive ( this number ) : float
number this The float we are ensuring is positive
Résultat float

EnsurePositive() public static méthode

Ensures that the specified integer is positive
public static EnsurePositive ( this number ) : int
number this The integer we are ensuring is positive.
Résultat int

ForceLength() public static méthode

Convert integer to string with a minimum length padding with "0" if int is to short.
public static ForceLength ( this number, int length ) : string
number this The number we are coverting to a fixed string length.
length int The length to fix the integer to.
Résultat string

Hours() public static méthode

Converts the number to hours as a TimeSpan
public static Hours ( this num ) : System.TimeSpan
num this Number representing hours
Résultat System.TimeSpan

HoursAgo() public static méthode

Returns a date in the past by hours.
public static HoursAgo ( this hours ) : System.DateTime
hours this The hours.
Résultat System.DateTime

HoursFromNow() public static méthode

Returns a date in the future by hours.
public static HoursFromNow ( this hours ) : System.DateTime
hours this The hours.
Résultat System.DateTime

IsEven() public static méthode

Returns true if number is even
public static IsEven ( this value ) : bool
value this The value to check.
Résultat bool

IsOdd() public static méthode

Returns true if number is odd
public static IsOdd ( this value ) : bool
value this
Résultat bool

Minutes() public static méthode

Converts the number of minutes as a TimeSpan
public static Minutes ( this num ) : System.TimeSpan
num this Number representing minutes
Résultat System.TimeSpan

MinutesAgo() public static méthode

Returns a date in the past by minutes
public static MinutesAgo ( this minutes ) : System.DateTime
minutes this The minutes.
Résultat System.DateTime

MinutesFromNow() public static méthode

Returns a date in the future by minutes.
public static MinutesFromNow ( this minutes ) : System.DateTime
minutes this The minutes.
Résultat System.DateTime

Seconds() public static méthode

Converts the number to seconds as a TimeSpan
public static Seconds ( this num ) : System.TimeSpan
num this
Résultat System.TimeSpan

SecondsAgo() public static méthode

Gets a date in the past according to seconds
public static SecondsAgo ( this seconds ) : System.DateTime
seconds this The seconds.
Résultat System.DateTime

SecondsFromNow() public static méthode

Gets a date in the future by seconds.
public static SecondsFromNow ( this seconds ) : System.DateTime
seconds this The seconds.
Résultat System.DateTime

Time() public static méthode

Converts the number to a TimeSpan.
public static Time ( this num ) : System.TimeSpan
num this Number reprsenting a timespan
Résultat System.TimeSpan

Time() public static méthode

Converts the military time to a timespan.
public static Time ( this num, bool convertSingleDigitsToHours ) : System.TimeSpan
num this
convertSingleDigitsToHours bool Indicates whether to treat "9" as 9 hours instead of minutes.
Résultat System.TimeSpan

ToBinary() public static méthode

Returns a binary string representation of the number.
public static ToBinary ( this number ) : string
number this The integer number to convert.
Résultat string

ToHex() public static méthode

Returns a hexadecimal string representation of the number.
public static ToHex ( this number ) : string
number this The integer number to convert.
Résultat string

ToHexChar() public static méthode

Convert an nibble value(4 bit) integer to its corresponding hex value
public static ToHexChar ( this nibble ) : int
nibble this
Résultat int

ToStringCurrentCulture() public static méthode

Returns a string representation using the Current culture
public static ToStringCurrentCulture ( this instance ) : string
instance this
Résultat string

ToStringInvariantCulture() public static méthode

Returns a string representation using an invariant culture
public static ToStringInvariantCulture ( this instance ) : string
instance this
Résultat string