Solved

ArrayList of Objects

Posted on 2006-06-15
3
223 Views
Last Modified: 2012-05-05
Hey Experts,

I have an object\class(Person.cs) with the following data:
private int age;
private string name;
private string address;
...

In another class, I:
ArrayList personObjectAL = new ArrayList( );
loop (add 10 people)
  {
     Person person = new Person( );
     person.age = age;
     person.name = name;
     person.adddres = address;
     ...
     personObjectAL.Add(person)
   }

How do I get the address of the 3rd entry?

Thank you!
0
Comment
Question by:codeshelp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16914471
string address = personObjectAL[2].address;
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 100 total points
ID: 16914518
sorry you need to cast the Object to a Person object first, it should be:

string address = ((Person) personObjectAL[2]).address;
0
 
LVL 3

Author Comment

by:codeshelp
ID: 16914614
Thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question