473,379 Members | 1,386 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,379 software developers and data experts.

How to use the List Class

I am a little bit confused on the concept of using a List Class. Here is what
I want to be able to do:

1) I create an object called "NotePage"
2) I want to add several "NotePage" objects to a "NoteBook" List
3) I then want to be able to pass a List Class as a parameter to a method call

Can anyone give me some examples on how to do this or at least point me in
the right direction? I am about to go nuts here.

Thanks.

--
Noble D. Bell
www.noblesoftware.com

Oct 3 '07 #1
3 1612
Noble,

It's pretty simple. You can do this:

// In your code:
List<NotePagenotebook = new List<NotePage>();

// Add your items.
notebook.Add(new NotePage());

And then pass notebook to your methods.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Noble Bell" <No*******@discussions.microsoft.comwrote in message
news:17**********************************@microsof t.com...
>I am a little bit confused on the concept of using a List Class. Here is
what
I want to be able to do:

1) I create an object called "NotePage"
2) I want to add several "NotePage" objects to a "NoteBook" List
3) I then want to be able to pass a List Class as a parameter to a method
call

Can anyone give me some examples on how to do this or at least point me in
the right direction? I am about to go nuts here.

Thanks.

--
Noble D. Bell
www.noblesoftware.com

Oct 3 '07 #2
Noble Bell wrote:
I am a little bit confused on the concept of using a List Class. Here is what
I want to be able to do:

1) I create an object called "NotePage"
2) I want to add several "NotePage" objects to a "NoteBook" List
3) I then want to be able to pass a List Class as a parameter to a method call

Can anyone give me some examples on how to do this or at least point me in
the right direction? I am about to go nuts here.
void SomeMethod(List<NotePagepages)
{
// ...
}

void SomeOtherMethod()
{
List<NotePageNoteBook = new List<NotePage>();
NotePage page = new NotePage();

NoteBook.Add(page);

SomeMethod(NoteBook);
}

Pete
Oct 3 '07 #3

You can also do this:
public class Employee
{}
public class EmployeeCollection : List <Employee>
{

}
This will give you instant strong typed collections.....a vast improvement
over 1.1 CollectionBase stuff.
You don't have to do this, you just ~can do this.

List <EmployeeallEmployees = new List <Employee>();

works as well.


"Noble Bell" <No*******@discussions.microsoft.comwrote in message
news:17**********************************@microsof t.com...
>I am a little bit confused on the concept of using a List Class. Here is
what
I want to be able to do:

1) I create an object called "NotePage"
2) I want to add several "NotePage" objects to a "NoteBook" List
3) I then want to be able to pass a List Class as a parameter to a method
call

Can anyone give me some examples on how to do this or at least point me in
the right direction? I am about to go nuts here.

Thanks.

--
Noble D. Bell
www.noblesoftware.com

Oct 3 '07 #4

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

Similar topics

5
by: Darryl B | last post by:
I can not get anywhere on this project I'm tryin to do. I'm not expecting any major help with this but any would be appreciated. The assignment is attached. The problem I'm having is trying to set...
8
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
5
by: Kenneth | last post by:
<list> seems to be a powerful structure to store the related nodes in memory for fast operations, but the examples I found are all related to primitive type storage. I'm doing a project on C++...
3
by: moondaddy | last post by:
I wrote my own List class which I use to bind to list controls. this class inherits CollectionBase and implements IBindingList. This class contains a list of business classes such as customers...
9
by: zacks | last post by:
I have written a serialized class that has several properties that are typed as a list of type class. When I deserialize an XML file, the list is populated just fine. But I am having trouble...
9
by: Naren | last post by:
Hi, why cant a list<derived*be implicitly castable to list<base*>? Any alternatives other than global operators? thanks in advance, Naren.
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
1
by: David Bilsby | last post by:
All Apologies for cross posing this but I am not sure if this is a VC 8 STL bug or simply an invalid use of the iterator. I have a PCI card access class which basically abstracts a third party...
12
by: isliguezze | last post by:
template <class T> class List { public: List(); List(const List&); List(int, const T&); void push_back(const T &); void push_front(const T &); void pop_back();
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.