Show / Hide Table of Contents

Class Int32Ex

Class containing some extension methods for System.Int32.

Inheritance
System.Object
Int32Ex
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class Int32Ex

Methods

| Improve this Doc View Source

April(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX