What does the addtion to the arraylist look like.
Assume you have a class Example with three properties Name, Age, Ht
respectively.
//I'm assuming an overloaded constructor that accepts three agruments
Example ex = new Example, ("john", 14, 56);
Example ex2 = new Example("sally", 67, 43);
Example ex3 = new Example("bill", 34, 76);
ArrayList al = new ArrayList();
al.Add(ex);
al.Add(ex2);
al.Add(ex3);
int i = ((Employee)al[1]).Age; will work for you or in VB.nET
Dim i as Integer = CType(al(1), Employee).Age
HTH,
Bill
--
W.G. Ryan MVP (Windows Embedded)
TiBA Solutions
www.tibasolutions.com |
www.devbuzz.com |
www.knowdotnet.com
"sal" <sa*@spp.net> wrote in message
news:Xn**********************@216.77.188.18...
Greets,
I'm trying to access individual records and fields of records in an
arraylist
but I'm having trouble. I thinks it's a syntax problem.
Why doesn't arraylist.age(1) give me '67' in the example below
what's the proper syntax? Can arraylist do this or do I have to switch to
a plan array?
Example
Name: Age: Ht:
john 14 56
sally 67 43
bill 34 76
Tia