Table of Contents

Class GetGenericEnumerable<T>

Namespace
Existential
Assembly
Existential.Net.dll

Provides methods to convert one or more items, or a non-generic collection, where possible, to a generic System.Collections.Generic.IEnumerable<T> collection of the specified type T.

public static class GetGenericEnumerable<T>

Type Parameters

T

The type of items to be contained by the returned collection.

Inheritance
System.Object
GetGenericEnumerable<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

Methods

From(T[])

Converts one or more items of type T to an IEnumerable of the same type.

public static IEnumerable<T> From(params T[] inItems)

Parameters

inItems T[]

The item or items to be converted to an IEnumerable.

Returns

System.Collections.Generic.IEnumerable<T>

An System.Collections.Generic.IEnumerable<T> containing the items.

From(IEnumerable)

Attempts to convert a non-generic System.Collections.IEnumerable to a generic System.Collections.Generic.IEnumerable<T>.

public static Maybe<IEnumerable<T>> From(IEnumerable inEnumerable)

Parameters

inEnumerable System.Collections.IEnumerable

The non-generic collection to convert.

Returns

Maybe<System.Collections.Generic.IEnumerable<T>>

A Maybe<T> of System.Collections.Generic.IEnumerable<T>. If the conversion is successful, it returns a Maybe<T> containing the converted System.Collections.Generic.IEnumerable<T>. If the conversion fails (e.g., due to type mismatch), it returns an empty Maybe<T>.

Remarks

This method is useful when you have a non-generic collection that you want to treat as a generic collection of a specific type. It attempts to cast the non-generic collection to a generic collection of the specified type. If the cast is successful, it wraps the generic collection in a Maybe<T> and returns it. If the cast fails (e.g., because the collection contains items of a different type), it returns an empty Maybe<T>.