2

i was just wondering about this

    Dim _Label As Label = Form1.Label1
    _Label.Text = "New Text" ' This work Form1.Label1.Text changed to  "New Text"

is this like ByRef is this pointer ,,, how this work ?

Al.Pertro
  • 175
  • 1
  • 6

1 Answers1

3

Yes, it is a pointer. In .NET, some types of variables always work like pointers while other types do not. In .NET, pointer types are called Reference Types while non-pointer types are called Value Types. Reference types are defined by classes. Value types are defined by structures. For instance:

Public Class MyReferenceType
    ' ...
End Class

Public Structure MyValueType
    ' ...
End Structure

Unlike some other languages, like C, where making a variable a pointer or not is determined separately for each variable, in .NET, it is defined once for the type and that decision globally affects all variables/objects of that type. Reference type objects (class objects) are always stored on the heap and value type objects (structure objects) are always stored on the stack.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
  • Ok ,Thank you ,Just one Q the new label will hold the Reference of the main label not all main label as same as pointers ? – Al.Pertro Jan 09 '14 at 19:19
  • I'm not exactly sure what you are asking. `Label` is a class. Therefore, any `Label` variable that you declare will always act as a pointer. Is that what you were asking? – Steven Doggart Jan 09 '14 at 19:21
  • 1
    Something close to that ,,, i think i get it ,thank you very much for your help , i can't vote you up cuze i have no noreputation. – Al.Pertro Jan 09 '14 at 19:27