Class Int32Ex
Class containing some extension methods for System.Int32.
Inheritance
Inherited Members
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class Int32Ex
Methods
| Improve this Doc View SourceApril(Int32, Int32)
Returns a date-time representing the specified day in April in the specified year.
Declaration
public static DateTime April(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in April in the specified year. |
August(Int32, Int32)
Returns a date-time representing the specified day in August in the specified year.
Declaration
public static DateTime August(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in August in the specified year. |
DaysInMonth(Int32, Int32)
Returns the number of days in the specified month of the specified year.
Declaration
public static int DaysInMonth(this int year, int month)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | year | The year. |
System.Int32 | month | The month. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the number of days of the specified month. For example February (2), the return value is 28 or 29 depending upon whether is a leap year. |
December(Int32, Int32)
Returns a date-time representing the specified day in December in the specified year.
Declaration
public static DateTime December(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in December in the specified year. |
FactorOf(Int32, Int32)
Checks if the Int32 value is a factor of the specified factor number.
Declaration
public static bool FactorOf(this int value, int factorNumer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The Int32 value to check. |
System.Int32 | 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. |
February(Int32, Int32)
Returns a date-time representing the specified day in February in the specified year.
Declaration
public static DateTime February(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in February in the specified year. |
IsEven(Int32)
Checks if the Int32 is even.
Declaration
public static bool IsEven(this int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The Int32 to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the Int32 is even, otherwise false. |
IsLeapYear(Int32)
Returns whether the given year is a leap year or not.
Declaration
public static bool IsLeapYear(this int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the year is a leap year, otherwise false. |
IsMultipleOf(Int32, Int32)
Checks if the Int32 value is a multiple of the given factor.
Declaration
public static bool IsMultipleOf(this int value, int factor)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The Int32 to check. |
System.Int32 | factor | The factor. |
Returns
Type | Description |
---|---|
System.Boolean | >Returns true if the Int32 value is a multiple of the given factor. |
Exceptions
Type | Condition |
---|---|
System.DivideByZeroException | factor is 0. |
IsOdd(Int32)
Checks if the Int32 is odd.
Declaration
public static bool IsOdd(this int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The Int32 to check. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the Int32 is odd, otherwise false. |
January(Int32, Int32)
Returns a date-time representing the specified day in January in the specified year.
Declaration
public static DateTime January(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in January in the specified year. |
July(Int32, Int32)
Returns a date-time representing the specified day in July in the specified year.
Declaration
public static DateTime July(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in July in the specified year. |
June(Int32, Int32)
Returns a date-time representing the specified day in June in the specified year.
Declaration
public static DateTime June(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in June in the specified year. |
March(Int32, Int32)
Returns a date-time representing the specified day in March in the specified year.
Declaration
public static DateTime March(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in March in the specified year. |
May(Int32, Int32)
Returns a date-time representing the specified day in May in the specified year.
Declaration
public static DateTime May(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in May in the specified year. |
November(Int32, Int32)
Returns a date-time representing the specified day in November in the specified year.
Declaration
public static DateTime November(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in November in the specified year. |
October(Int32, Int32)
Returns a date-time representing the specified day in October in the specified year.
Declaration
public static DateTime October(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in October in the specified year. |
PercentageOf(Int32, Decimal)
Gets the specified percentage of the number.
Declaration
public static decimal PercentageOf(this int number, decimal percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | number | The number. |
System.Decimal | percent | The percent. |
Returns
Type | Description |
---|---|
System.Decimal | Returns the specified percentage of the number |
PercentageOf(Int32, Double)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this int number, double percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | number | The number. |
System.Double | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Int32, Int32)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this int number, int percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | number | The number. |
System.Int32 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentageOf(Int32, Int64)
Gets the specified percentage of the number.
Declaration
public static double PercentageOf(this int number, long percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | number | The number. |
System.Int64 | percent | The percent. |
Returns
Type | Description |
---|---|
System.Double | Returns the specified percentage of the number |
PercentOf(Int32, Double)
Gets the percentage of the number.
Declaration
public static double PercentOf(this int number, double total)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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(Int32, Int32)
Gets the percentage of the number.
Declaration
public static double PercentOf(this int number, int total)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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. |
RangeTo(Int32, Int32)
Returns a list containing all values of the given range.
Declaration
public static List<int> RangeTo(this int startValue, int endValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startValue | The start of the range. |
System.Int32 | endValue | The end of the range. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<T><System.Int32> | Returns a list containing the specified range. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The start value can not be greater than the end value. |
September(Int32, Int32)
Returns a date-time representing the specified day in September in the specified year.
Declaration
public static DateTime September(this int day, int year)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | day | The day. |
System.Int32 | year | The year. |
Returns
Type | Description |
---|---|
System.DateTime | Return a date-time representing the specified day in September in the specified year. |
Sum(Int32, Int32[])
Computes the sum of a sequence of the given values.
Declaration
public static int Sum(this int value, params int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The first value. |
System.Int32[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int32.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum(Nullable<Int32>, Nullable<Int32>[])
Computes the sum of a sequence of the given values.
Declaration
public static int ? Sum(this int ? value, params int ? [] values)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<T><System.Int32> | value | The first value. |
System.Nullable<T><System.Int32>[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Int32> | Returns the sum of the values. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | The sum is larger than System.Int32.MaxValue |
System.ArgumentNullException | values can not be null. |
Sum<TSource>(TSource, Func<TSource, Int32>, TSource[])
Computes the sum of the sequence of System.Int32 values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static int Sum<TSource>(this TSource value, Func<TSource, int> selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Int32> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Int32 | 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.Int32.MaxValue |
System.ArgumentNullException | selector can not be null. |
Sum<TSource>(TSource, Func<TSource, Nullable<Int32>>, TSource[])
Computes the sum of the sequence of nullable System.Int32 values that are obtained by invoking a transform function on each element of the input sequence.
Declaration
public static int ? Sum<TSource>(this TSource value, Func<TSource, int ? > selector, params TSource[] values)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The first value. |
System.Func<T, TResult><TSource, System.Nullable<T><System.Int32>> | selector | A transform function to apply to each element. |
TSource[] | values | The other values. |
Returns
Type | Description |
---|---|
System.Nullable<T><System.Int32> | 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.Int32.MaxValue |
System.ArgumentNullException | selector can not be null. |
ToDays(Int32)
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 int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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(Int32)
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 int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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(Int32)
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 int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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(Int32)
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 int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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(Int32)
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 int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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. |