Post.Cast Method
Cast<TSource, TTarget>(TSource)
At post-compile time, casts an instance of a type into another. A post-compile time error is reported if the source type cannot be assigned to the target type.
Declaration
public static TTarget Cast<TSource, TTarget>(TSource o)
where TSource : class where TTarget : class
Parameters
Type | Name | Description |
---|---|---|
TSource | o | Instance to be casted. |
Returns
Type | Description |
---|---|
TTarget | The object |
Type Parameters
Name | Description |
---|---|
TSource | Source type. |
TTarget | Target type. |