tags:

views:

17

answers:

1

So if I create an object test, and it has a property color. When I add this object to an array list I typically can access this using myarray(0).color but intellisense doesn't 'know' that I have a 'test' object inside the array. It would let me type myarray(0).whatever but would then crash if I made typo. It seems like I should be able to let it know what type of object I am trying to work with inside the arraylist.

In code maybe something like this

dim testobject as new test
testobject.color = "red"
dim testarray as new arraylist
testarray.add(testobject)

testarray(0).color = "blue"

Could someone tell me the name of this concept, and a more correct(if there is one) of how I should be doing this?

Thanks for any thoughts!

+1  A: 

use generics instead

dim a as System.collections.generic.List(of test) 
a(0).asf  ' Errror 
rerun
great! Is this the concept loosly typed versus strongly typed?
mellerbeck
Exactly Generics are strongly typed
rerun