Jump to content

Recommended Posts

Posted

Hi y'all,

 

First off, I have to do generic overload of the method, because I can't change the old code.

And here it is:

*** *** public Obj ReturnObject(Obj obj)

*** *** {

*** *** *** return obj;

*** *** }

the normal version of the method, not so strong type.

Then I wrap around it with:

*** *** public T ReturnObject(T obj) where T : Obj

*** *** {

*** *** *** Obj obj1 = ReturnObject(obj);// trying to call the non-generic method

*** *** *** return obj1 as T;

*** *** }

So I don't have to do casting all the time.

But Obj obj1 = ReturnObject(obj); always callback to the same generic method again and again instead of calling the non-generic method.

 

Is it a feature or a bug?

 

If this is a feature, then how would I, or could I, call the non-generic method of similar signature?

 

I guess I can change the name of the methods to be different from each other, but then why do I want that?

 

Thank you for your advices!

 

 

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...