Cadenza : Cadenza Namespace

Int32Coda Class

Extension methods for int.

public static class Int32Coda

Remarks

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Members

See Also: Inherited members from object.

Public Methods

static
DownTo (this int, int) : IEnumerable<int>
Creates an IEnumerable<int> which will return the values from self down to limit, inclusive.
static
IsEven (this int) : bool
Gets a value indicating whether value is an even number.
static
IsOdd (this int) : bool
Gets a value indicating whether value is an odd number.
static
Step (this int, int, int) : IEnumerable<int>
Creates an IEnumerable<int> which will return the values from self up to limit, inclusive, incrementing by step between each value.
static
Times (this int) : IEnumerable<int>
Creates an IEnumerable<int> which will return the values between 0 and self, exclusive.
static
UpTo (this int, int) : IEnumerable<int>
Creates an IEnumerable<int> which will return the values from self up to limit, inclusive.

Member Details

DownTo Method

Creates an IEnumerable<int> which will return the values from self down to limit, inclusive.

public static IEnumerable<int> DownTo (this int self, int limit)

See Also

IEnumerableCoda.Apply``1(IEnumerable<``0>, Action<``0>)
IEnumerableCoda.Apply``1(IEnumerable<``0>)

Parameters

self
An int containing the upper starting value.
limit
An int containing the lower ending value.

Returns

An IEnumerable<int> with values between self down to limit, inclusive.

Remarks

This method is implemented by using deferred execution.

Note: No bounds checking is performed, so if limit is greater than self, then (int.MaxValue - self - limit) values will be returned.

Example

The following example demonstrates use of Int32Coda.DownTo(int, int):

C# Example
Console.WriteLine (5.DownTo (0).Implode (", "));
    // Prints "5, 4, 3, 2, 1, 0"

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IsEven Method

Gets a value indicating whether value is an even number.

public static bool IsEven (this int value)

See Also

Int32Coda.IsOdd(int)

Parameters

value
A int containing the value to check.

Returns

true if value is an even number; otherwise, false.

Remarks

For purposes of this method, an even value is a number evenly divisible by 2 and the number 0; all other numbers are odd.

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

IsOdd Method

Gets a value indicating whether value is an odd number.

public static bool IsOdd (this int value)

See Also

Int32Coda.IsEven(int)

Parameters

value
A int containing the value to check.

Returns

true if value is an odd number; otherwise, false.

Remarks

For purposes of this method, an even value is a number evenly divisible by 2 and the number 0; all other numbers are odd.

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Step Method

Creates an IEnumerable<int> which will return the values from self up to limit, inclusive, incrementing by step between each value.

public static IEnumerable<int> Step (this int self, int limit, int step)

See Also

IEnumerableCoda.Apply``1(IEnumerable<``0>, Action<``0>)
IEnumerableCoda.Apply``1(IEnumerable<``0>)

Parameters

self
An int containing the lower starting value.
limit
An int containing the upper ending value.
step
An In32 containing the value to increment by.

Returns

An IEnumerable<int> with values between self up to limit, inclusive.

Remarks

This method is implemented by using deferred execution.

Note: No bounds checking is performed, so if limit is less than self, then ((int.MaxValue - self - limit) / step) values will be returned.

Example

The following example demonstrates use of Int32Coda.Step(int, int, int):

C# Example
Console.WriteLine (1.Step(9, 2).Implode (", "));
    // Prints "1, 3, 5, 7, 9"

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

Times Method

Creates an IEnumerable<int> which will return the values between 0 and self, exclusive.

public static IEnumerable<int> Times (this int self)

See Also

IEnumerableCoda.Apply``1(IEnumerable<``0>, Action<``0>)
IEnumerableCoda.Apply``1(IEnumerable<``0>)

Parameters

self
An int containing the positive upper limit.

Returns

An IEnumerable<int> with values between 0 up to self exclusive.

Exceptions

Type Reason
ArgumentOutOfRangeException self is less than 0.

Remarks

This method is implemented by using deferred execution.

Example

The following example demonstrates use of Int32Coda.Times(int):

C# Example
Console.WriteLine (6.Times ().Implode (", "));
    // Prints "0, 1, 2, 3, 4, 5"

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0

UpTo Method

Creates an IEnumerable<int> which will return the values from self up to limit, inclusive.

public static IEnumerable<int> UpTo (this int self, int limit)

See Also

IEnumerableCoda.Apply``1(IEnumerable<``0>, Action<``0>)
IEnumerableCoda.Apply``1(IEnumerable<``0>)

Parameters

self
An int containing the lower starting value.
limit
An int containing the upper ending value.

Returns

An IEnumerable<int> with values between self up to limit, inclusive.

Remarks

This method is implemented by using deferred execution.

Note: No bounds checking is performed, so if limit is less than than self, then (int.MaxValue - self - limit) values will be returned.

Example

The following example demonstrates use of Int32Coda.UpTo(int, int):

C# Example
Console.WriteLine (6.UpTo (12).Implode (", "));
    // Prints "6, 7, 8, 9, 10, 11, 12"

Requirements

Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0