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
  • 42,597
  • 8
  • 69
  • 103