Class Int64Ex
Class containing some extension methods for System.Int32.
Inheritance
Inherited Members
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class Int64Ex
Methods
| Improve this Doc View SourceFactorOf(Int64, Int64)
Checks if the Int64 value is a factor of the specified factor number.
Declaration
public static bool FactorOf(this long value, long factorNumer)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The Int64 value to check. |
System.Int64 | factorNumer | The factor number. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the value is a factor of the specified factor number, otherwise false. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | value is 0. |
IsEven(Int64)
Checks if the Int64 is even.
Declaration
public static bool IsEven(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The Int64 to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the Int64 is even, otherwise false. |
IsMultipleOf(Int64, Int64)
Checks if the Int64 value is a multiple of the given factor.
Declaration
public static bool IsMultipleOf(this long value, long factor)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The Int64 to check. |
System.Int64 | factor | The factor. |
Returns
Type | Description |
---|---|
System.Boolean | >Returns true if the Int64 value is a multiple of the given factor. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | factor is 0. |
IsOdd(Int64)
Checks if the Int64 is odd.
Declaration
public static bool IsOdd(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The Int64 to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the Int64 is odd, otherwise false. |
PercentageOf(Int64, Decimal)
Gets the specified percentage of the number.
Declaration
public static decimal PercentageOf(this long number, decimal percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Decimal | percent | The percent. |
Returns
Type | Description |
---|---|
System.Decimal | Returns the specified percentage of the number |
PercentageOf(Int64, Double)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this long number, double percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Double | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Int64, Int32)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this long number, int percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Int32 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Int64, Int64)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this long number, long percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Int64 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentOf(Int64, Double)
Gets the percentage of the number.
Declaration
public static double PercentOf(this long number, double total)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Double | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
PercentOf(Int64, Int32)
Gets the percentage of the number.
Declaration
public static double PercentOf(this long number, int total)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Int32 | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
PercentOf(Int64, Int64)
Gets the percentage of the number.
Declaration
public static double PercentOf(this long number, long total)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The number. |
System.Int64 | total | The total value. |
Returns
Type | Description |
---|---|
System.Double | Returns the percentage of the number. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | The number must be greater than zero. |
RangeTo(Int64, Int64)
Returns a list containing all values of the given range.
Declaration
public static List<long> RangeTo(this long startValue, long endValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | startValue | The start of the range. |
System.Int64 | endValue | The end of the range. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T><System.Int64> | Returns a list containing the specified range. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The start value can not be greater than the end value. |
Sum(Int64, Int64[])
Computes the sum of a sequence of the given values.
Declaration
public static long Sum(this long value, params long[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The first value. |
System.Int64[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Int64 | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int64.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum(Nullable<Int64>, Nullable<Int64>[])
Computes the sum of a sequence of the given values.
Declaration
public static long ? Sum(this long ? value, params long ? [] values)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<T><System.Int64> | value | The first value. |
System.Nullable<T><System.Int64>[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Int64> | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int64.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum<TSource>(TSource, Func<TSource, Int64>, TSource[])
Computes the sum of the sequence of System.Int64 values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static long Sum<TSource>(this TSource value, Func<TSource, long> selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Int64> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Int64 | Returns the sum of the projected values. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int64.MaxValue |
System.ArgumentNullException | selector can not be null. |
Sum<TSource>(TSource, Func<TSource, Nullable<Int64>>, TSource[])
Computes the sum of the sequence of nullable System.Int64 values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static long ? Sum<TSource>(this TSource value, Func<TSource, long ? > selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Nullable<T><System.Int64>> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Int64> | Returns the sum of the projected values. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int64.MaxValue |
System.ArgumentNullException | selector can not be null. |
ToDays(Int64)
Returns a System.TimeSpan that represents a specified number of days, where the specification is accurate to the nearest millisecond.
Declaration
public static TimeSpan ToDays(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A number of days. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns a System.TimeSpan representing the given value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | value is less than System.TimeSpan.MinValue or greater than System.TimeSpan.MaxValue. |
ToHours(Int64)
Returns a System.TimeSpan that represents a specified number of hours, where the specification is accurate to the nearest millisecond.
Declaration
public static TimeSpan ToHours(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A number of hours. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns a System.TimeSpan representing the given value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | value is less than System.TimeSpan.MinValue or greater than System.TimeSpan.MaxValue. |
ToMilliseconds(Int64)
Returns a System.TimeSpan that represents a specified number of milliseconds, where the specification is accurate to the nearest millisecond.
Declaration
public static TimeSpan ToMilliseconds(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A number of milliseconds. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns a System.TimeSpan representing the given value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | value is less than System.TimeSpan.MinValue or greater than System.TimeSpan.MaxValue. |
ToMinutes(Int64)
Returns a System.TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.
Declaration
public static TimeSpan ToMinutes(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A number of minutes. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns a System.TimeSpan representing the given value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | value is less than System.TimeSpan.MinValue or greater than System.TimeSpan.MaxValue. |
ToSeconds(Int64)
Returns a System.TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.
Declaration
public static TimeSpan ToSeconds(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A number of seconds. |
Returns
Type | Description |
---|---|
System.TimeSpan | Returns a System.TimeSpan representing the given value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | value is less than System.TimeSpan.MinValue or greater than System.TimeSpan.MaxValue. |