reference an object by its name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

I have a tricky question. Suppose I have a member or local variable named
XYZ.
I want to reference the object using a string, "XYZ".

In code, I want to do the following.

Checkbox MyCheckbox = (Checkbox) doSomething("XYZ");

Is this possible in .NET? If so, how can I do it?

Thanks. Stay cool.
 
Using reflection you can access uninstantiated classes, but I do not think
that you can access objects via a string. References to objects to not have
names, only the variable that holds then does. What you might try doing is
using a Hashtable which can store your object references and let you access
then via a named identifier.
 
No,

This is the difference between a program language and the scripting
language, this is always a kind of late binding what cost performance, while
there is almost no reason except that the background of the programmer is a
scripting language.

Just my thought,

Cor.
 
Back
Top