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
valueintThe integer to cube.
Returns
- int
valueto the power of 3.
Half(int)
Returns half of the given integer, rounded toward zero.
public static int Half(this int value)
Parameters
valueintThe integer to halve.
Returns
- int
valuedivided by 2.
IsEven(int)
Determines whether the given number is even.
public static bool IsEven(this int value)
Parameters
valueintThe 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
valueintThe 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
valueintThe integer to square.
Returns
- int
valuemultiplied 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
valueintThe month number (1-12).
cultureCultureInfoThe 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"