Hi,
I have my own class and I'd like to save objects of this class in a
dictionary. In python this works something along the lines of:
a = MyObject();
b = MyObject();
c = MyObject();
myObjectDict = {}
myObjectDict['a'] = a
myObjectDict['b'] = b
myObjectDict['c'] = c
How do I do this in C#?
Thanks,
Barry
Marc Gravell - 23 Oct 2007 12:52 GMT
(assumes 2.0, and note that I'm interpreting 'a' as a string not a
char - hope this is correct ;-p)
using System.Collections.Generic;
...
MyObject a = new MyObject(), b = new MyObject(), c = new MyObject();
Dictionary<string, MyObject> dict = new Dictionary<string,
MyObject>();
dict["a"] = a;
dict["b"] = b;
dict["c"] = c;
Marc