|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Explict generic methodsclass 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 Kevin Burton wrote:
> Do C# generic methods support explicit implementation? No.-- Barry "Kevin Burton" <KevinBur***@discussions.microsoft.com> wrote in message You mean specialization? No, specialization is not supported for generics.news:D73EA179-DE69-4946-8CB0-8F0480781611@microsoft.com... > Do C# generic methods support explicit implementation? Within a non > generic Show quote > class I would like to define explicit implementations for methods. For Just use overloaded prototypes, no generic needed there.> 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? Show quote > > Thank you. > > Kevin > > 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 > > > > > > > |
|||||||||||||||||||||||