Ok, thanks. But does using the 'name' property really enable you to refer to
the
object using the supplied name?
If you write
label1.Name = "something";
then I want to use the name "something" (which is a string and can be called
from somewhere else) and not "label1" (which is the assigned name of the
pointer to the object when creating the object) to refer to the Label object.
"Marc Gravell" wrote:
Actually, "label1" is NOT the name of the object; that is the local name of
a variable *pointing* at the object. Note that once compiled to IL,
variables don't have names.
The Label class probably does have a .Name property (depending on which
"Label" class this is...); this can be anything you want. When using the IDE
to place e.g. Controls onto Forms, then yes: the IDE keeps the two
identical. But that is only for the designer's benefit, not yours.
So yes, just: label1.Name = "something";
Marc