Re: Why can't overloads take into account the return type.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"mdb" <m_b_r_a_y@c_t_i_u_s_a__d0t__com> wrote in message
news:Xns9654C594F8C15mbrayctiusacom@xxxxxxxxxxxxxxxx
> Because the function call and assigning the result are two completely
> different things.

In VB6 the return value was just another parameter under the hood. The
actual return value was the error code, which I presume is the same in C#.
Someone correct me if i'm wrong.

> You don't even have to assign the result. So, tell
> me... For example, what would happen if I did these:

In any of those cases it would give an error in exactly the same way as it
would if it couldn't resolve an overload. See code below.

> I'm sure you can see how ridiculous this would get if it did consider
> return type...

Not at all. In this case the developer has chosen to have the return type
part of the signature by creating 2 overloads with the only difference being
the return type. Because it can be turned on and off I can't see any problem
with it.

Michael

[STAThread]
static void Main()
{
DoIt(null);
}

static void DoIt(Class1 SomeValue)
{
}

static void DoIt(Class2 SomeValue)
{
}


.



Relevant Pages