Home All Groups Group Topic Archive Search About

Explict generic methods

Author
9 Jan 2007 6:13 PM
Kevin Burton
Do C# generic methods support explicit implementation? Within a non generic
class I would like to define explicit implementations for methods. For
example:

class A
{
    static void Method<T>;
}

Now I need someway to define explicit implementations. I need definitions so
that each of the following call a different explicit implementation.

A.Method<int>;
A.Method<string>;

I get syntax errors any way I try to define a generic method. Any ideas?

Thank you.

Kevin

Author
9 Jan 2007 6:17 PM
Barry Kelly
Kevin Burton wrote:

> Do C# generic methods support explicit implementation?

No.

-- Barry

Author
9 Jan 2007 7:33 PM
Ben Voigt
"Kevin Burton" <KevinBur***@discussions.microsoft.com> wrote in message
news:D73EA179-DE69-4946-8CB0-8F0480781611@microsoft.com...
> Do C# generic methods support explicit implementation? Within a non
> generic
You mean specialization?  No, specialization is not supported for generics.


Show quote
> class I would like to define explicit implementations for methods. For
> example:
>
> class A
> {
>    static void Method<T>;
> }
>
> Now I need someway to define explicit implementations. I need definitions
> so
> that each of the following call a different explicit implementation.
>
> A.Method<int>;
> A.Method<string>;
>
> I get syntax errors any way I try to define a generic method. Any ideas?
Just use overloaded prototypes, no generic needed there.

Show quote
>
> Thank you.
>
> Kevin
>
>
Author
9 Jan 2007 8:01 PM
Kevin Burton
That is what I meant. I was coming from the C++ world of templates. Thank you
for your response.

Show quote
"Ben Voigt" wrote:

>
> "Kevin Burton" <KevinBur***@discussions.microsoft.com> wrote in message
> news:D73EA179-DE69-4946-8CB0-8F0480781611@microsoft.com...
> > Do C# generic methods support explicit implementation? Within a non
> > generic
> You mean specialization?  No, specialization is not supported for generics.
>
>
> > class I would like to define explicit implementations for methods. For
> > example:
> >
> > class A
> > {
> >    static void Method<T>;
> > }
> >
> > Now I need someway to define explicit implementations. I need definitions
> > so
> > that each of the following call a different explicit implementation.
> >
> > A.Method<int>;
> > A.Method<string>;
> >
> > I get syntax errors any way I try to define a generic method. Any ideas?
> Just use overloaded prototypes, no generic needed there.
>
> >
> > Thank you.
> >
> > Kevin
> >
> >
>
>
>

AddThis Social Bookmark Button