473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Generics.

Hi,

I've recently read the articles on generics in the .net
framework (the next version) and just wanted to check a
few points..

As I understand, generic class instances while being
strongly typed checked at compile time, are only created
at runtime?? Is this correct??

Secondly, can you inherit from a typed generic class??
i.e.
public class MySortedList:GenericSortedList<int32>
{
}

ANy feedback would be sweet..

thanks..

Eddie
Jul 21 '05 #1
3 1999
Hi Eddie

This is from memory of a session at an MS conference, so it might not be
100% correct.

Generics will be type checked at compile time, and a class created for each
class type and value type that uses them. For instance, if you have multiple
lists containing ints, the internally only one set of code will be required
to handle the lot. The generics in Rotor do not do this.

I'm not sure that the issue of inheritance was discussed. I just assumed you
can inherit. Take a look at the Rotor generics - they should tell you.

Regards

Ron

"Eddie" <no*@important.com> wrote in message
news:07****************************@phx.gbl...
Hi,

I've recently read the articles on generics in the .net
framework (the next version) and just wanted to check a
few points..

As I understand, generic class instances while being
strongly typed checked at compile time, are only created
at runtime?? Is this correct??

Secondly, can you inherit from a typed generic class??
i.e.
public class MySortedList:GenericSortedList<int32>
{
}

ANy feedback would be sweet..

thanks..

Eddie

Jul 21 '05 #2
We're planning to introduce generics starting with Visual Studio "Whidbey,"
which we won't be talking a lot about until the Professional Developers
Conference at the end of this month. If you want more information, check on
MSDN the week of October 28th.

Thanks,
John

Director, Product Management
..NET Framework
Microsoft
Jul 21 '05 #3


--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Eddie" <no*@important.com> wrote in message
news:07****************************@phx.gbl...
Hi,

I've recently read the articles on generics in the .net
framework (the next version) and just wanted to check a
few points..

As I understand, generic class instances while being
strongly typed checked at compile time, are only created
at runtime?? Is this correct??
The IL to implement a specific use of a generic class (ie List<int>) is
created at JIT time, unless it's already been created. Each value type needs
a separate set of IL, but reference types can share their IL.
Secondly, can you inherit from a typed generic class??
i.e.
public class MySortedList:GenericSortedList<int32>
{
}


Yes.
Jul 21 '05 #4

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

Similar topics

27
2440
by: Bernardo Heynemann | last post by:
How can I use Generics? How can I use C# 2.0? I already have VS.NET 2003 Enterprise Edition and still can´t use generics... I´m trying to make a generic collection myCollection<vartype> and...
2
3081
by: Mr.Tickle | last post by:
So whats the deal here regarding Generics in the 2004 release and templates currently in C++?
23
2518
by: Luc Vaillant | last post by:
I need to initialise a typed parameter depending of its type in a generic class. I have tried to use the C++ template form as follow, but it doesn't work. It seems to be a limitation of generics...
12
2715
by: Michael S | last post by:
Why do people spend so much time writing complex generic types? for fun? to learn? for use? I think of generics like I do about operator overloading. Great to have as a language-feature, as...
5
2909
by: anders.forsgren | last post by:
This is a common problem with generics, but I hope someone has found the best way of solving it. I have these classes: "Fruit" which is a baseclass, and "Apple" which is derived. Further I have...
11
2468
by: herpers | last post by:
Hello, I probably don't see the obvious, but maybe you can help me out of this mess. The following is my problem: I created two classes NormDistribution and DiscDistribution. Both classes...
9
5947
by: sloan | last post by:
I'm not the sharpest knife in the drawer, but not a dummy either. I'm looking for a good book which goes over Generics in great detail. and to have as a reference book on my shelf. Personal...
1
2417
by: Vladimir Shiryaev | last post by:
Hello! Exception handling in generics seems to be a bit inconsistent to me. Imagine, I have "MyOwnException" class derived from "ApplicationException". I also have two classes...
7
3239
by: SpotNet | last post by:
Hello NewsGroup, Reading up on Generics in the .NET Framework 2.0 using C# 2005 (SP1), I have a question on the application of Generics. Knowingly, Generic classes are contained in the...
13
3792
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an...
0
7202
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
7280
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,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
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
4672
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...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.