Re: polymorphism/boxing question
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 22 Feb 2007 21:51:00 -0000
<lorenzon@xxxxxxxxx> wrote:
quick update by self:
after looking into it it almost seems like this is impossible as I
read that C# determines which overload to invoke for a given call at
compile time. This seems to me to be lame, and kind of hobbles
polymorphism doesn't it? At least I should be able to unbox my
variable from its generic interface type and have the call made on it
then.
Okay, to start with: there's no boxing involved in your examples.
Boxing is a matter of representing a value type value as a reference
type instance. You haven't shown any value types being involved at all.
And yes, you're right: overloading is performed at compile time. That
doesn't hobble polymorphism, however, which is more about *overriding*
than overloading.
"Double dispatch" may be the answer to your issues, however. See
http://en.wikipedia.org/wiki/Double_dispatch
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- polymorphism/boxing question
- From: lorenzon
- Re: polymorphism/boxing question
- From: lorenzon
- polymorphism/boxing question
- Prev by Date: Re: Executing a JavaScript command from a web service
- Next by Date: Re: Single Instance Form
- Previous by thread: Re: polymorphism/boxing question
- Next by thread: Re: polymorphism/boxing question
- Index(es):
Relevant Pages
|