✅ Casting from one generic type to another
Hi,
I've got the following:
However, it's telling me that I can't do this as it can't cast
Value
to TValue
.
How would I go about getting it to allow this, as I specifically only want to get to that point in the code if they are of the same type.
The reason for doing it like this is because I need to keep a reference to the base class elsewhere where I don't know the type.
Thanks3 Replies
Use an
as
cast instead of the final cast. You'll need an extra null check
Or use the as cast firstor
Value is TValue tValue
Thanks