In .net, most types -- particularly stuff as complex as Windows controls -- are reference types. This means the variable's value is just a reference to an object, and you're just copying references -- not whole objects -- when you assign variables of those types. The big result being that in your example, changing myControl
would change myPanel
(and vice versa), because the two refer to the same object.
To be sure, check the documentation. If the object's type inherits from System.ValueType
(or System.Enum
, which extends ValueType
as well), then it's a value type, and the whole thing will get copied when you assign. Otherwise it's a reference type, and you're just copying references.