C++ templates in C#

  • Thread starter Thread starter Bob Weiner
  • Start date Start date
B

Bob Weiner

Hi,

Forgive me if this has already been discussed but does C# have a construct
like C++ templates?

bob
 
For additional clarity, Generics in 2.0 aren't exactly like templates.
Managed C++, for example will support both. Generics are generic objects
that produce a specific generic type and specifically typed associated
types. A template is basically a code generator. Both have advantages and
disadvantages. Primarily, templates are capable of a number of things
generics aren't, but only work in the language you are currently using,
while generics give you constraints and cross language support.
 
I should additionally note that 2.0 Generics are not a C# thing, they are a
CLR thing. Generics have been implemented at the IL level in the CLR so
that C#, VB and MC++ will support them. There may be others.
--
Sam Gentile
MVP - .NET/C#
http://samgentile.com/blog/
Disclaimer: Please do not contact me directly, use the newsgroup
 
Sam Gentile said:
I should additionally note that 2.0 Generics are not a C# thing, they are a
CLR thing. Generics have been implemented at the IL level in the CLR so
that C#, VB and MC++ will support them. There may be others.
Hopefully atleast Delphi and Eiffel. One of the things that bothers me the
most about generics is that they are not CLS compliant(currently anyway),
which basically means that *most*, if not all classes I write will have to
choose between compliance and generics(and, worse yet, where should the
framework stand?). The lack of CLS Compliance really takes a big piece of of
generics gleen.
 
Hi Bob,

I think the community's further reply is of much value.

Do you still have any concern?
If you still have anything unclear, please feel free to tell me. I will
help you.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top