Demo : Cadenza Namespace

ObjectCoda Class

Extension methods on object.

public static class ObjectCoda

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: Cadenza
Assembly: Demo (in Demo.dll)
Assembly Versions: 0.0.0.0

Members

See Also: Inherited members from object.

Public Methods

static
With<TSource,TResult> (this TSource, Func<TSource, TResult>) : TResult
Supports chaining otherwise temporary values.

Member Details

With<TSource,TResult> Generic Method

Supports chaining otherwise temporary values.

public static TResult With<TSource, TResult> (this TSource self, Func<TSource, TResult> selector)

Type Parameters

TSource
The type to operate on.
TResult
The type to return.

Parameters

self
A TSource containing the value to manipulate. This value may be null (unlike most other extension methods).
selector
A Func<TSource, TResult> which will be invoked with self as a parameter.

Returns

The value of type TResult returned by selector.

Exceptions

Type Reason
ArgumentNullException selector is null.

Remarks

With is useful for easily using an intermediate value within an expression "chain" without requiring an explicit variable declaration (which is useful for reducing in-scope variables, as no variable is explicitly declared).

C# Example
Console.WriteLine(
    args.OrderBy(v => v)
    .With(c => c.ElementAt (c.Count()/2)));

Requirements

Namespace: Cadenza
Assembly: Demo (in Demo.dll)
Assembly Versions: 0.0.0.0