C# Класс Utilities.Extensions.NumberExtensions

Показать файл Открыть проект

Открытые методы

Метод Описание
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

Описание методов

Days() публичный статический Метод

Converts the number to days as a TimeSpan.
public static Days ( this num ) : System.TimeSpan
num this Number representing days
Результат System.TimeSpan

DaysAgo() публичный статический Метод

Returns a date in the past by given number of days.
public static DaysAgo ( this days ) : System.DateTime
days this The days.
Результат System.DateTime

DaysFromNow() публичный статический Метод

Returns a date in the future by days.
public static DaysFromNow ( this days ) : System.DateTime
days this The days.
Результат System.DateTime

EnsurePositive() публичный статический Метод

Ensures that the specified float is positive
public static EnsurePositive ( this number ) : float
number this The float we are ensuring is positive
Результат float

EnsurePositive() публичный статический Метод

Ensures that the specified integer is positive
public static EnsurePositive ( this number ) : int
number this The integer we are ensuring is positive.
Результат int

ForceLength() публичный статический Метод

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.
Результат string

Hours() публичный статический Метод

Converts the number to hours as a TimeSpan
public static Hours ( this num ) : System.TimeSpan
num this Number representing hours
Результат System.TimeSpan

HoursAgo() публичный статический Метод

Returns a date in the past by hours.
public static HoursAgo ( this hours ) : System.DateTime
hours this The hours.
Результат System.DateTime

HoursFromNow() публичный статический Метод

Returns a date in the future by hours.
public static HoursFromNow ( this hours ) : System.DateTime
hours this The hours.
Результат System.DateTime

IsEven() публичный статический Метод

Returns true if number is even
public static IsEven ( this value ) : bool
value this The value to check.
Результат bool

IsOdd() публичный статический Метод

Returns true if number is odd
public static IsOdd ( this value ) : bool
value this
Результат bool

Minutes() публичный статический Метод

Converts the number of minutes as a TimeSpan
public static Minutes ( this num ) : System.TimeSpan
num this Number representing minutes
Результат System.TimeSpan

MinutesAgo() публичный статический Метод

Returns a date in the past by minutes
public static MinutesAgo ( this minutes ) : System.DateTime
minutes this The minutes.
Результат System.DateTime

MinutesFromNow() публичный статический Метод

Returns a date in the future by minutes.
public static MinutesFromNow ( this minutes ) : System.DateTime
minutes this The minutes.
Результат System.DateTime

Seconds() публичный статический Метод

Converts the number to seconds as a TimeSpan
public static Seconds ( this num ) : System.TimeSpan
num this
Результат System.TimeSpan

SecondsAgo() публичный статический Метод

Gets a date in the past according to seconds
public static SecondsAgo ( this seconds ) : System.DateTime
seconds this The seconds.
Результат System.DateTime

SecondsFromNow() публичный статический Метод

Gets a date in the future by seconds.
public static SecondsFromNow ( this seconds ) : System.DateTime
seconds this The seconds.
Результат System.DateTime

Time() публичный статический Метод

Converts the number to a TimeSpan.
public static Time ( this num ) : System.TimeSpan
num this Number reprsenting a timespan
Результат System.TimeSpan

Time() публичный статический Метод

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.
Результат System.TimeSpan

ToBinary() публичный статический Метод

Returns a binary string representation of the number.
public static ToBinary ( this number ) : string
number this The integer number to convert.
Результат string

ToHex() публичный статический Метод

Returns a hexadecimal string representation of the number.
public static ToHex ( this number ) : string
number this The integer number to convert.
Результат string

ToHexChar() публичный статический Метод

Convert an nibble value(4 bit) integer to its corresponding hex value
public static ToHexChar ( this nibble ) : int
nibble this
Результат int

ToStringCurrentCulture() публичный статический Метод

Returns a string representation using the Current culture
public static ToStringCurrentCulture ( this instance ) : string
instance this
Результат string

ToStringInvariantCulture() публичный статический Метод

Returns a string representation using an invariant culture
public static ToStringInvariantCulture ( this instance ) : string
instance this
Результат string