Declaring a type with identifier as an expression

  • Thread starter Thread starter Rabih
  • Start date Start date
R

Rabih

Hi
How do you dynamically declare a type using an expression
for the identifier.

eg :

for x =1 to 10
Dim myObj+str(x) as object
next


Many thanks
 
Rabih said:
How do you dynamically declare a type using an expression
for the identifier.

eg :

for x =1 to 10
Dim myObj+str(x) as object
next

Generally, you don't - you use an array or map of some kind (such as
Hashtable) instead. Now, why do you particularly *want* to do it in
this case?
 
You must use an array:

Dim myObj(10) As Object
myObj(1) = "Wert 1"
myObj(2) = "Wert 2"
Console.WriteLine(myObj(2)) 'Writes "Wert2" to the console
 
Back
Top