Table of Contents

Class IntegerExtensions

Namespace
HeroKit.Integers
Assembly
HeroKit.dll

Provides extension methods for integers.

public static class IntegerExtensions
Inheritance
IntegerExtensions
Inherited Members

Methods

Cube(int)

Returns the cube of the given integer.

public static int Cube(this int value)

Parameters

value int

The integer to cube.

Returns

int

value to the power of 3.

Half(int)

Returns half of the given integer, rounded toward zero.

public static int Half(this int value)

Parameters

value int

The integer to halve.

Returns

int

value divided by 2.

IsEven(int)

Determines whether the given number is even.

public static bool IsEven(this int value)

Parameters

value int

The number to check.

Returns

bool

True if the number is even; otherwise false.

IsOdd(int)

Determines whether the given number is odd. Works for negative numbers.

public static bool IsOdd(this int value)

Parameters

value int

The number to check.

Returns

bool

True if the number is odd; otherwise false.

Square(int)

Returns the square of the given integer.

public static int Square(this int value)

Parameters

value int

The integer to square.

Returns

int

value multiplied by itself.

ToMonthName(int, CultureInfo?)

Returns the name of the month with the given number.

public static string ToMonthName(this int value, CultureInfo? culture = null)

Parameters

value int

The month number (1-12).

culture CultureInfo

The culture for the month name. Defaults to CurrentCulture, because the result is meant for display.

Returns

string

The month name, or an empty string if the value is out of range.

Examples

3.ToMonthName(CultureInfo.GetCultureInfo("tr-TR")); // "Mart"