Can you create instances named at runtime?
-
I want to create an instance of a class, the instance being named by the user at runtime. So i can put that instance in an arraylist and refer to it by name later (for removing and searching purposes). Is this possible?(& how?) or am i better off just cycling through the arraylist and searching for the significant identifier in each record. (in this case the Student Number) Thank you.
-
I want to create an instance of a class, the instance being named by the user at runtime. So i can put that instance in an arraylist and refer to it by name later (for removing and searching purposes). Is this possible?(& how?) or am i better off just cycling through the arraylist and searching for the significant identifier in each record. (in this case the Student Number) Thank you.
See the sample for Hashtable on MSDN. It's what you need: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionshashtableclasstopic.asp[^] If the number of elements is very low (~<= 5), it's faster using an ArrayList, but usually the best thing is using a Hashtable. Yes, even I am blogging now!