<small id='D0CsU'></small><noframes id='D0CsU'>

    • <bdo id='D0CsU'></bdo><ul id='D0CsU'></ul>

  1. <i id='D0CsU'><tr id='D0CsU'><dt id='D0CsU'><q id='D0CsU'><span id='D0CsU'><b id='D0CsU'><form id='D0CsU'><ins id='D0CsU'></ins><ul id='D0CsU'></ul><sub id='D0CsU'></sub></form><legend id='D0CsU'></legend><bdo id='D0CsU'><pre id='D0CsU'><center id='D0CsU'></center></pre></bdo></b><th id='D0CsU'></th></span></q></dt></tr></i><div id='D0CsU'><tfoot id='D0CsU'></tfoot><dl id='D0CsU'><fieldset id='D0CsU'></fieldset></dl></div>

    <tfoot id='D0CsU'></tfoot>

  2. <legend id='D0CsU'><style id='D0CsU'><dir id='D0CsU'><q id='D0CsU'></q></dir></style></legend>

      我可以访问内部类中的外部类对象吗

      时间:2023-09-15
        <bdo id='VTXll'></bdo><ul id='VTXll'></ul>
          <tbody id='VTXll'></tbody>
        <legend id='VTXll'><style id='VTXll'><dir id='VTXll'><q id='VTXll'></q></dir></style></legend>

        <small id='VTXll'></small><noframes id='VTXll'>

        1. <i id='VTXll'><tr id='VTXll'><dt id='VTXll'><q id='VTXll'><span id='VTXll'><b id='VTXll'><form id='VTXll'><ins id='VTXll'></ins><ul id='VTXll'></ul><sub id='VTXll'></sub></form><legend id='VTXll'></legend><bdo id='VTXll'><pre id='VTXll'><center id='VTXll'></center></pre></bdo></b><th id='VTXll'></th></span></q></dt></tr></i><div id='VTXll'><tfoot id='VTXll'></tfoot><dl id='VTXll'><fieldset id='VTXll'></fieldset></dl></div>

            • <tfoot id='VTXll'></tfoot>

                本文介绍了我可以访问内部类中的外部类对象吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有三个这样的课程.

                class A
                {
                    public class innerB
                       {
                       //Do something
                       }
                
                    public class innerC
                       {
                        //trying to access objB here directly or indirectly over here. 
                        //I dont have to create an object of innerB, but to access the object created by A
                        //i.e.
                             innerB objInnerB = objB;
                        //not like this
                             innerB objInnerB= new innerB();
                       }
                
                private innerB objB{get;set;}  **//Private**
                
                public A()
                   {
                    objB= new innerB();
                   }
                }
                

                我想访问由 A 类创建的 C 类中 B 类的对象.是否有可能以某种方式对 C 类中 A 类的对象进行更改.我可以通过创建事件或任何方式来获取 A 类的对象吗?

                I want to access the object of class B in Class C that is created by class A. Is it possible somehow to make changes on object of Class A in Class C. Can i get Class A's object by creating event or anyhow.

                我提出上述问题的错误.在 A 中创建的 B 的对象是私有的而不是公共的

                是否可以通过创建事件来做到这一点

                IS IT POSSIBLE TO DO THIS BY CREATING EVENT

                如果我能够引发一个 A 类可以处理的事件,那么我的问题就可以解决了.

                If anyhow I become able to raise an event that can be handled by Class A, then my problem can be solved.

                推荐答案

                如果我没看错,你想在 innerC 中访问类 A 的 objB 属性而不传递它.

                If I'm reading you correctly you want to access the objB property of class A within innerC WITHOUT passing it along.

                这不是 C# 内部类的工作方式,如本文所述:C# 嵌套类就像 C++ 嵌套类,而不是 Java 内部类

                This isn't how C# inner classes work, as described in this article: C# nested classes are like C++ nested classes, not Java inner classes

                如果您想从 innerC 访问 A.objB,那么您将不得不以某种方式将 A 类传递给 innerC.

                If you want to access A.objB from innerC then you are going to have to somehow pass class A to innerC.

                这篇关于我可以访问内部类中的外部类对象吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何使用委托和事件处理程序进行用户控制 下一篇:如何删除所有 Click 事件处理程序?

                相关文章

              • <i id='lM9EK'><tr id='lM9EK'><dt id='lM9EK'><q id='lM9EK'><span id='lM9EK'><b id='lM9EK'><form id='lM9EK'><ins id='lM9EK'></ins><ul id='lM9EK'></ul><sub id='lM9EK'></sub></form><legend id='lM9EK'></legend><bdo id='lM9EK'><pre id='lM9EK'><center id='lM9EK'></center></pre></bdo></b><th id='lM9EK'></th></span></q></dt></tr></i><div id='lM9EK'><tfoot id='lM9EK'></tfoot><dl id='lM9EK'><fieldset id='lM9EK'></fieldset></dl></div>

                  <small id='lM9EK'></small><noframes id='lM9EK'>

                  <tfoot id='lM9EK'></tfoot>
                1. <legend id='lM9EK'><style id='lM9EK'><dir id='lM9EK'><q id='lM9EK'></q></dir></style></legend>

                      <bdo id='lM9EK'></bdo><ul id='lM9EK'></ul>