IntegerExtensions Class
Definition
- Namespace
- Cuemon.Extensions
- Assemblies
- Cuemon.Extensions.Core.dll
public static class IntegerExtensions
- Inheritance
-
objectIntegerExtensions
Examples
The following example demonstrates how to use the IntegerExtensions extension methods to check whether a given integer is prime, even, or odd, and to find the smallest or largest of two values.
using System;
using Cuemon.Extensions;
namespace MyApp.Examples;
public static class IntegerExtensionsExample
{
public static void Demonstrate()
{
var number = 17;
bool isPrime = number.IsPrime();
bool isEven = number.IsEven();
bool isOdd = number.IsOdd();
Console.WriteLine(isPrime);
Console.WriteLine(isEven);
Console.WriteLine(isOdd);
Console.WriteLine(5.Max(10));
Console.WriteLine(15.Min(10));
Console.WriteLine(500L.Min(1000L));
Console.WriteLine(((short)3).Max((short)7));
Console.WriteLine(new[] { 1, 3, 5, 7 }.IsCountableSequence());
}
}
Methods
| Name | Description |
|---|---|
| IsCountableSequence(IEnumerable<int>) | Determines whether the specified |
| IsCountableSequence(IEnumerable<long>) | Determines whether the specified |
| IsEven(int) | Determines whether the specified |
| IsOdd(int) | Determines whether the specified |
| IsPrime(int) | Determines whether the specified |
| Max(short, short) | Returns the larger of two 16-bit signed integers. |
| Max(int, int) | Returns the larger of two 32-bit signed integers. |
| Max(long, long) | Returns the larger of two 64-bit signed integers. |
| Min(short, short) | Returns the smaller of two 16-bit signed integers. |
| Min(int, int) | Returns the smaller of two 32-bit signed integers. |
| Min(long, long) | Returns the smaller of two 64-bit signed integers. |