Vb.net Pointers

前端 未结 5 2057
执念已碎
执念已碎 2021-01-14 16:20

What is the most similar thing in vb.net to a pointer, meaning like C poinetrs?

I have a TreeView within a class. I need to expose some specific nodes (or leaves) th

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-14 16:59

    C#, and I also believe VB.Net, will work on the concept of references. Essentially, it means when you say

    A a = new A()

    the 'a' is a reference, and not the actual object.

    So if I go

    B b = a

    b is another reference to the same underlying object.

    When you want to expose any internal objects, you can simply do so by exposing 'properties'. Make sure, that you do not provide setters for the properties, or that if you do, there is code to check if the value is legal.

    ByRef is used when you want to pass the object as a parameter, and when you want the called method to be able to change the reference (as opposed to the object).

    As mentioned above, if you post some code, it will be easier to explain.

提交回复
热议问题