Click or drag to resize
AlgorithmsTypedAsT Method (IList)
Given a non-generic IList interface, wrap a generic IList<T> interface around it. The generic interface will enumerate the same objects as the underlying non-generic list, but can be used in places that require a generic interface. The underlying non-generic list must contain only items that are of type T or a type derived from it. This method is useful when interfacing older, non-generic lists to newer code that uses generic interfaces.

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
public static IList<T> TypedAs<T>(
	IList untypedList
)

Parameters

untypedList
Type: System.CollectionsIList
An untyped list. This list should only contain items of type T or a type derived from it.

Type Parameters

T
The item type of the wrapper list.

Return Value

Type: IListT
A generic IList<T> wrapper around untypedList. If untypedList is null, then null is returned.
Remarks
Some collections implement both generic and non-generic interfaces. For efficiency, this method will first attempt to cast untypedList to IList<T>. If that succeeds, it is returned; otherwise, a wrapper object is created.
See Also