We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Overhead of using ArrayLists and Hashtables in C#

Hi - I am really getting dynamic with my form and control creation from a backend schema and building the controls on the fly from a DataSet. I need to reference the objects I create in methods and because the control is declared locally in each method e.g. CreateTextBox() { TextBox tb = new TextBox(); // set properties } I need to later reference this object. I was thinking of putting my controls in both Hashtables for immediate reference by a key and into an ArrayList to decide which controls are bound to the database. My question is, since both of these objects hold references to control object I create - is there much overhead to do this? Having say 100 controls instantiated, then added to the form, then added to a Hashtable and finally to an ArrayList. Does the ArrayList and Hashtable cause much memory allocation or are they just pointers to the memory address of those objects and therefore could be considered lightweight? thanks for your expertise - much appreciated mike

Live Chat Icon For mobile
Up arrow icon