Connecting Tech Pros Worldwide Help | Site Map

How to use the List Class

=?Utf-8?B?Tm9ibGUgQmVsbA==?=
Guest
 
Posts: n/a
#1: Oct 3 '07
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

Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#2: Oct 3 '07

re: How to use the List Class


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]
- mvp@spam.guard.caspershouse.com

"Noble Bell" <NobleBell@discussions.microsoft.comwrote in message
news:17EEB309-67EF-4FB8-8A79-C2E76FA4982C@microsoft.com...
Quote:
>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
>

Peter Duniho
Guest
 
Posts: n/a
#3: Oct 3 '07

re: How to use the List Class


Noble Bell wrote:
Quote:
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
sloan
Guest
 
Posts: n/a
#4: Oct 4 '07

re: How to use the List Class



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" <NobleBell@discussions.microsoft.comwrote in message
news:17EEB309-67EF-4FB8-8A79-C2E76FA4982C@microsoft.com...
Quote:
>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
>

Closed Thread