Hi all. Is there any collection object that will let me create a list of items which I could call by name, instead of by number? so instead of soing this:

//Create List
List<ClassType> list = new List<ClassType>();

//Assign values to list
list.add(new ClassType(params, [params, [params]]));

//Call list items
list[0].method();
list[1].method();

i do this:

//Create List
List<ClassType> list = new List<ClassType>();

//Assign values to list
list.add(new ClassType("id", [params, [params]]));

//Call list items
list["id1"].method();
list["id2"].method();

I have a query manager class which has a string for every table, in order to call just the tables i need, so, by calling the List items by id makes the association easier, since i assign an id for the table, as much as for the List item referencing the table.

Thanks

Dictionary is the answer.

Dictionary<string, Numbers> a = new Dictionary<string, Numbers>();
     a.Add("a1", new Numbers());
     a.Add("a2", new Numbers());
     a["a1"].A1();
     a["a2"].A1();

I knew i was close when i thought about IDictionaryEnumerator... now... should i use IDictionary or Dictionary

Solved... thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.