Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

How to use the List Class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Noble Bell - 03 Oct 2007 17:55 GMT
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.

Signature

Noble D. Bell
www.noblesoftware.com

Nicholas Paldino [.NET/C# MVP] - 03 Oct 2007 18:15 GMT
Noble,

   It's pretty simple.  You can do this:

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

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

   And then pass notebook to your methods.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I am a little bit confused on the concept of using a List Class. Here is
>what
[quoted text clipped - 9 lines]
>
> Thanks.
Peter Duniho - 03 Oct 2007 18:18 GMT
> I am a little bit confused on the concept of using a List Class. Here is what
> I want to be able to do:
[quoted text clipped - 5 lines]
> 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<NotePage> pages)
    {
        // ...
    }

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

        NoteBook.Add(page);

        SomeMethod(NoteBook);
    }

Pete
sloan - 03 Oct 2007 23:54 GMT
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 <Employee> allEmployees = new List <Employee>();

works as well.

>I am a little bit confused on the concept of using a List Class. Here is
>what
[quoted text clipped - 9 lines]
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.