Jump to content

Recommended Posts

Posted

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

 

interfaceMyInterface

{

** T GetValue ();

}

 

 

and in code I would like some generic code*to do something like this:

 

MyStringClass : MyInterface

 

 

MyStringClass sc = new MyStringClass () ;

...

...

if (sc is MyInterface)

{

** MyInterface*dc = (MyInterface )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.

 

 

 

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...