Skip to content

Cannot cast the type into its generic parameter using operator (op_Implicit or op_Explicit) even if nothing runs wrong (using reflection) #94633

Answered by saucecontrol
CaryCatZ asked this question in General
Discussion options

You must be logged in to vote

From:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/type-testing-and-cast#as-operator

The as operator considers only reference, nullable, boxing, and unboxing conversions. You can't use the as operator to perform a user-defined conversion. To do that, use a cast expression.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CaryCatZ
Comment options

Answer selected by CaryCatZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants