I'm looking to define string variables from an array of strings.
x(2) = {"bar","foo"}
How do I create variables out of bar and foo? And then how do I assign them a value?
I'm looking to define string variables from an array of strings.
x(2) = {"bar","foo"}
How do I create variables out of bar and foo? And then how do I assign them a value?
Use a Dictionary(Of String,String)
Dim x() As String = {"bar", "foo"}
Dim dict As New Dictionary(Of String, String)
For Each s In x
dict.Add(s, "your value")
Next
You can read/write the values very easy and fast:
dict("foo") = "another value"
The array-value is the key for the dictionary entry. Every key must be unique.
There is no such thing as the associate array in .net Like what joel suggests, you can use a dictionary
//in c#:
Dictionary<string, string> myDictionary = new Dictionary<string, string>();
myDictionary.Add("bar", "x");
myDictionary.Add("foo", "fooValue");
string barValue = myDictionary["bar"];