References in VB.NET

后端 未结 6 1933
無奈伤痛
無奈伤痛 2021-01-06 19:05

Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I am about to ask can be answered by a little bit of testing, but I was wondering if any

6条回答
  •  难免孤独
    2021-01-06 19:22

    In this line:

    Dim tempClass as New UsingClass(Reference)
    

    the object referred to by the Reference property is passed "by value", but it's not the object that is copied, it's the reference to that object that is copied (i.e. myReference and tempClass.Reference are two distinct "pointers" to the same object. You could then do tempClass.Reference = new ReferenceClass and then myReference and tempClass.Reference are still two distinct "pointers", but now they each point to two different objects.

提交回复
热议问题