EnumerableExtensions.Cast method
Version 1.1.28
.NET Framework 4.8
| Namespace | Skybrud.Essentials.Collections.Extensions |
|---|---|
| Assembly | Skybrud.Essentials.dll |
Cast(IEnumerable, Type)
Extension method
Casts the elements of an IEnumerable to the specified targetType.
public static IEnumerable Cast(this IEnumerable source, Type targetType)
Parameters
source
IEnumerable
The IEnumerable that contains the elements to be cast to targetType.
targetType
Type
Returns
An IEnumerable that contains each element of the source sequence cast to the specified type.
Remarks
The System.Linq.Enumerable.Cast``1(System.Collections.IEnumerable) method requires developers to know the target type at compile time. Using the non-generic Skybrud.Essentials.Collections.Extensions.EnumerableExtensions.Cast(System.Collections.IEnumerable,System.Type) method instead, the target type can be specified at runtime.