473,670 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List definition

I have the following code:
*************** *************** *********
public class Test
{
....

public static TestCollection MyNewCollection ()
{
}
}

// Define Collections here
public class TestCollection : List<Test>
*************** *************** ******

What is this doing here?

I assume that I have a class of Test and the last line allows me to make
class that is just a collection (array) of objects of type Test.

Is that what is happening here?

I then saw some code that did something like:

....
List<TestmyList :
....

Which would define "myList" as a collection of objects of type Test?

Is this what is happening?

Thanks,

Tom
Dec 13 '07 #1
1 2105
On Thu, 13 Dec 2007 11:07:38 -0800, tshad <ts***@dslextre me.comwrote:
[...]
// Define Collections here
public class TestCollection : List<Test>
*************** *************** ******

What is this doing here?

I assume that I have a class of Test and the last line allows me to make
class that is just a collection (array) of objects of type Test.

Is that what is happening here?
The last line creates a new class that _inherits_ the List<Testclass.
The List<Testclass itself is a concrete version of the generic List<T>
class, which is not exactly an array. It's sort of a merged version of
Array and ArrayList, with typed elements like an Array has, but with the
dynamic features of ArrayList.

By inheriting it, the TestCollection class can add its own functionality
to the base List<Testbehavi or. I would not bother inheriting List<Test>
unless that extension was specifically needed or desired. You might as
well just use List<Testdirect ly instead.
I then saw some code that did something like:

...
List<TestmyList :
...

Which would define "myList" as a collection of objects of type Test?
Yes. It declares myList as a specific kind of collection of objects of
type Test. .NET has a wide variety of collection types, and the generic
List<Ttype is just one of them.

Perhaps more important for you to understand is that the "<T>" part is not
unique to collections. The collection classes happen to be one of the
more prominent uses of generics in the framework, but generics are not
used solely for collections. So in that example, it's the "List" part
that is the important thing with respect to the type being a collection;
the "<Test>" part is just part of the way you declare that particular kind
of collection (that is, using a generic class).

Pete
Dec 13 '07 #2

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

Similar topics

2
2994
by: Steve | last post by:
Hi, I have a very long string, someting like: DISPLAY=localhost:0.0,FORT_BUFFERED=true, F_ERROPT1=271\,271\,2\,1\,2\,2\,2\,2,G03BASIS=/opt/g03b05/g03/basis, GAMESS=/opt/gamess,GAUSS_ARCHDIR=/opt/g03b05/g03/arch, GAUSS_EXEDIR=/opt/g03b05/g03/bsd:/opt/g03b05/g03/private:/opt/g03b05/g
57
4270
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
1379
by: gencode | last post by:
How do I get the list of overrides for a ASP.NET page in C# I can get my PageEvent by selecting MyPage System.Web.UI.Page and selecting the Lightingbolt, that gives me a list of page events like AbortTransaction, Load, Unload, etc. But I can not seem to find the overrideables like AddedControl, OnPrerender, OnLoad, Visible. The only option I see is to manually add them in, is there another way?
43
2710
by: michael.f.ellis | last post by:
The following script puzzles me. It creates two nested lists that compare identically. After identical element assignments, the lists are different. In one case, a single element is replaced. In the other, an entire column is replaced. --------------------------------------------------------------------------------------- ''' An oddity in the behavior of lists of lists. Occurs under Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
5
2673
by: Bryan | last post by:
Hi, Where is the proper place to use a member initialization list, the header or cpp file? Does it make any difference? Also, is there any difference between using a member initialization list and initializaing member variables in the constructor?
2
4953
by: menyki | last post by:
error c: ......line 3: unable to open include file 'stdio.h error c: ....... line 4: unable to open include file 'stdlib.h' error c: ........line 5: unable to open include file 'time.h' error c: ........line 12: unidentified symbol 'null' in function intmain error c:.........line 24: unidentified symbol 'price' in function intmain error c:.........line 24: invalid indirection in function intmain error c: .......line 25: statement missing ;...
3
2664
by: maruf.syfullah | last post by:
Consider the following Class definitions: class AClass { int ai1; int ai2; public: CClass* c; AClass(){}
6
4493
by: Timur Tabi | last post by:
Is there a way I can have the browser automatically insert a blank line after each definition in a definition list? Right now I have this: term-1 definition text .... term -2 definition text ... I'd like to have this:
36
2888
by: pereges | last post by:
Hi, I am wondering which of the two data structures (link list or array) would be better in my situation. I have to create a list of rays for my ray tracing program. the data structure of ray looks like this: typedef struct { vector origin; /* vector is an array of 3 doubles */
11
4157
by: Juha Nieminen | last post by:
Assume we have this: std::list<Typelist1(10, 1), list2(20, 2); std::list<Type>::iterator iter = list1.end(); list1.swap(list2); What happens here, according to the standard? 1) 'iter' still points to list1::end(). 2) 'iter' now points to list2::end().
0
8468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7415
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4209
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1792
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.