473,326 Members | 2,127 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,326 software developers and data experts.

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 1991
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
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
by: Mr.Tickle | last post by:
So whats the deal here regarding Generics in the 2004 release and templates currently in C++?
23
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.