I was wondering if there is anyway to down cast a generic interface?
What I whant to do is something like this, I have an interface like this
interface MyInterface<T>
{
T GetValue ();
}
and in code I would like some generic code to do something like this:
MyStringClass : MyInterface<string>
MyStringClass sc = new MyStringClass () ;
...
...
if (sc is MyInterface<object>)
{
MyInterface<object> dc = (MyInterface<object> )sc ;
object o = dc.GetValue () ;
}
I'm pretty sure that I can't do this and it would be best to add a second non generic interface that does the cast for me.
Any comments?
Cheers,
Stephen.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.