How to pass this by ref in C#?

后端 未结 5 1910
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 17:27

In a class (ClassA) of mine I want to create a related instance of another class (ClassB) providing it with a reference to the object who has initiated it\'s creation. So I\

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 18:26

    You don't need to pass by ref in this case. If you are passing ClassB(this), it will be passed by reference and not by value anyway. Any changes made to the classA instance passed into classB's constructor will be applied to class A as well.

提交回复
热议问题