jes12345
asked on
Indexed arrays in VB.NET
Hi - I am new to VB.NET and I have a question I hope someone can assist with.
In PHP the code below is valid. Is there a similar array type in VB?
In PHP the code below is valid. Is there a similar array type in VB?
$price['Gasket'] = 15.29;
$price['Wheel'] = 75.25;
$price['Tire'] = 50.00;
echo $price[Tire];
I think you would have to use a HashTable rather than a simple array.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Fantastic! Thanks - just what I was after. Just a follow up question. When you declare the Dictionary object I assume the second parameter is telling what sort of values each entry will hold? Is this optional and if yes what is default type?
Thanks J
Thanks J
You are correct. The first parameter is the type for the key and the second is the type for the value. The second parameter is required, but you can specify it as Object if you don't want a fixed type. But if you use Object as the second parameter then you may as well just use a HashTable.
ASKER
Quick and excellent advise
ASKER
Brilliant - I am sure will use this collection on many occations in the future - many thanks for your advise. J