Tag Property References?
-
I have Class A with Properties Foo and Bar and Class B which has an indexer to an Array of Class A objects. I have a button for each element in B's array of A's. I want to refer to these A objects through the Tag property of each button:
private B b = new B(2); // contructs array[2] of Class A objects, but both are null button1.Tag = b[0]; button2.Tag = b[1];
I think my problem lies in the fact that many times the elements in the array will be null, which leaves the tags as null. I would like the tag, however, to refer to the space in the array in the Class B object, so I can do something like :(A)button1.Tag = new A(FOO, BAR);
thereby creating a new Class A object within b's array. Along with this I would like to be able to set the properties like:((A)button2.Tag).Foo = NEWFOO;
I come from C++ so I always think in pointers. Do I need pointers to do this, or just a different approach? Tym!