Link to home
Start Free TrialLog in
Avatar of jes12345
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?
$price['Gasket'] = 15.29;
$price['Wheel']  = 75.25;
$price['Tire']   = 50.00;
echo $price[Tire];

Open in new window

Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

I think you would have to use a HashTable rather than a simple array.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jes12345
jes12345

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
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.
Quick and excellent advise
Brilliant - I am sure will use this collection on many occations in the future - many thanks for your advise. J