473,411 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

C++ templates in C#

Hi,

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

bob
Nov 15 '05 #1
7 1585
2.0 Generics.

"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:#J**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

bob

Nov 15 '05 #2
yep, that what i'm looking for. Thanks!

<.> wrote in message news:Ob**************@TK2MSFTNGP10.phx.gbl...
2.0 Generics.

"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:#J**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

bob


Nov 15 '05 #3
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.
"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
yep, that what i'm looking for. Thanks!

<.> wrote in message news:Ob**************@TK2MSFTNGP10.phx.gbl...
2.0 Generics.

"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:#J**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

bob



Nov 15 '05 #4
Naturally, you should read this:

http://www.artima.com/intv/generics.html

A very good article! Bill Venners really rocks.

Bob Weiner wrote:
yep, that what i'm looking for. Thanks!

<.> wrote in message news:Ob**************@TK2MSFTNGP10.phx.gbl...
2.0 Generics.

"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:#J**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

bob



Nov 15 '05 #5
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
-----
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:ez**************@TK2MSFTNGP11.phx.gbl...
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.
"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
yep, that what i'm looking for. Thanks!

<.> wrote in message news:Ob**************@TK2MSFTNGP10.phx.gbl...
> 2.0 Generics.
>
> "Bob Weiner" <bo*@engr.uconn.edu> wrote in message
> news:#J**************@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > Forgive me if this has already been discussed but does C# have a

construct
> > like C++ templates?
> >
> > bob
> >
> >
>
>



Nov 15 '05 #6

"Sam Gentile [MVP]" <sa*@nomail.com> wrote in message
news:ul**************@TK2MSFTNGP11.phx.gbl...
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. --
Sam Gentile
MVP - .NET/C#
http://samgentile.com/blog/
Disclaimer: Please do not contact me directly, use the newsgroup
-----
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:ez**************@TK2MSFTNGP11.phx.gbl...
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.
"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
yep, that what i'm looking for. Thanks!

<.> wrote in message news:Ob**************@TK2MSFTNGP10.phx.gbl...
> 2.0 Generics.
>
> "Bob Weiner" <bo*@engr.uconn.edu> wrote in message
> news:#J**************@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > Forgive me if this has already been discussed but does C# have a
construct
> > like C++ templates?
> >
> > bob
> >
> >
>
>



Nov 15 '05 #7

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.

Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
22
by: E. Robert Tisdale | last post by:
According to the C++ FAQ Lite: http://www.parashift.com/ What is "genericity"? Yet another way to say, "class templates." Not to be confused with "generality" (which just means avoiding...
12
by: Fabio De Francesco | last post by:
Hello. I can't understand why I can't compile the following simple code, where I think I have applied all the needed rules for templates that are declared and defined in different files (*.h and...
16
by: WittyGuy | last post by:
Hi, What is the major difference between function overloading and function templates? Thanks! http://www.gotw.ca/resources/clcm.htm for info about ]
2
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
25
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
28
by: NewToCPP | last post by:
Hi, I am just trying to find out if there is any strong reason for not using Templates. When we use Templates it is going to replicate the code for different data types, thus increasing the...
104
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a...
7
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.