How to pass this by ref in C#?

后端 未结 5 1903
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  [愿得一人]
    2020-12-03 18:03

    You can't change the this pointer, which is something that the ref keyword allows. Why can't you declare ClassB like this?

    ClassA m_classA;
    public ClassB(ClassA classA)
    {
       m_classA = classA;
    }
    

提交回复
热议问题