How do i cast A to object to class A when B can typcast to A?
Posted
by acidzombie24
on Stack Overflow
See other posts from Stack Overflow
or by acidzombie24
Published on 2010-03-21T11:26:42Z
Indexed on
2010/03/21
11:41 UTC
Read the original article
Hit count: 382
Basically i want to do this. ee causes a bad cast exception.
NOTE: o can be ANYTHING. It may not be B, it can be C, D, E, F etc. But this should work as long as o is a class that can typecast into A (B is such a class. It uses an implicit operator overload)
var b = (B)"sz";
var e = (A)b;
object o = b;
var ee = (A)o;
© Stack Overflow or respective owner