Being new to C# (coming from PHP) I'm at a lose as to how to do this.
have an array of items where the structure is something like this:
myArray[String AccountNumber]
{
String name;
String City;
Decimal balance;
}
I've tried things like:
Using a Hashtable, but only seemed to allow me to store one item in
its value.
Then I moved on to Dictonaries with something like Dictionary<String,
Hashtable>
Dictionary<String, HashtablefooBar = new Dictionary<String,
Hashtable>();
Hashtable myHashTable = new HashTable;
accountNumber = "1234";
myHashtable.Add("user","Foo");
myHashtable.Add("Pass","Bar");
myHashtable.Add("Balance",22);
fooBar.Add(accountNumber, myHashTable);
myHashtable.Clear(); //clear it out or Index already exists error will
be thrown
accountNumber="2345";
myHashtable.Add("user","Benny");
myHashtable.Add("Pass","Hill");
myHashtable.Add("Balance",22);
fooBar.Add(accountNumber, myHashTable);
myHashtable.Clear(); //clear out or Index already exists error will be
thrown.
myHashtable = fooBar['1234"]; //This should load the stored hashtable
in to myHashtable
But doing like the above, myHashTable does not contain any values. :(
In PHP it is easy enough:
$orange["123"] = array("Foo","Bar",36);
$orange["456"] = array("Benny", "Hill", 22);
echo $orange["456"][0];
So how would I go about something like that in C#? Collections,
Dictionaries, and HashTables. Oh my!
I've looked through various books on C# but nothing comes close to
describing what I'm trying to do. :(
Thanks.