What's the easiest way to create a collection of key, value1, value2 ?
Important to me is that it is easy & short to retrieve either value1 or value2 given the pair (please show an example)
I know I can do this -
class MyObject
{
internal string NameA { get; set; }
internal string NameB { get; set; }
}
class Other
{
Dictionary<string, MyObject> MyObjectCollection { get; set; }
private void function()
{
MyObjectCollection = new Dictionary<string, MyObject>()
{ { "key", new MyObject { NameA = "something", NameB = "something else" } } };
var valueA = MyObjectCollection["key"].NameA; // = "something"
}
}
Is there a better way?