public void DoSomething<T>(object value)
{
<code omitted>
}

public void DoSomething<T>()
{
How do I now call this.DoSomething<T>(null);
}



Thanks


Pete

Re: Calling an overloaded generic method by Nicholas

Nicholas
Thu Aug 28 10:09:40 CDT 2008

Pete,

You will have to cast the null, like so:

this.DoSomething<T>((object) null);


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Peter Morris" <mrpmorrisNO@SPAMgmail.com> wrote in message
news:eLZx5yRCJHA.4884@TK2MSFTNGP02.phx.gbl...
> public void DoSomething<T>(object value)
> {
> <code omitted>
> }
>
> public void DoSomething<T>()
> {
> How do I now call this.DoSomething<T>(null);
> }
>
>
>
> Thanks
>
>
> Pete



Re: Calling an overloaded generic method by Peter

Peter
Thu Aug 28 11:13:16 CDT 2008

Ahh. I thought it *should* work. Thanks!


Pete

Re: Calling an overloaded generic method by Pavel

Pavel
Fri Aug 29 02:01:55 CDT 2008

On Aug 28, 6:45=A0pm, "Peter Morris" <mrpmorri...@SPAMgmail.com> wrote:
> public void DoSomething<T>(object value)
> {
> =A0 =A0 <code omitted>
>
> }
>
> public void DoSomething<T>()
> {
> =A0 =A0 How do I now call this.DoSomething<T>(null);
>
> }

With the code as written, it should be just "DoSomething<T>(null)" -
there are no ambiguities here. Perhaps you've meant the first
signature to be "DoSomething<T>(T)"? Then you could either use the
cast as suggested, or explicitly specify T on call:
"DoSomething<object>(null)".

Re: Calling an overloaded generic method by Pavel

Pavel
Fri Aug 29 02:02:14 CDT 2008

On Aug 28, 6:45=A0pm, "Peter Morris" <mrpmorri...@SPAMgmail.com> wrote:
> public void DoSomething<T>(object value)
> {
> =A0 =A0 <code omitted>
>
> }
>
> public void DoSomething<T>()
> {
> =A0 =A0 How do I now call this.DoSomething<T>(null);
>
> }

With the code as written, it should be just "DoSomething<T>(null)" -
there are no ambiguities here. Perhaps you've meant the first
signature to be "DoSomething<T>(T)"? Then you could either use the
cast as suggested, or explicitly specify T on call:
"DoSomething<object>(null)".