類A由類B,類C,公共變量D等構成,
在B中如何能夠得到D的值呢?

解决方案 »

  1.   

    將什么申明為Protected? 是D嗎?
      

  2.   

    暈死~~~
    原來以為很簡單得一個問題,想不到卻沒有人能夠解決!
    郁悶~~~~~
    是CSDN沒有人還是我的問題太難啊? 這么基本得問題都解決不了!
      

  3.   

    汗死
    protect子类就可以通过继承得到父类的变量,如果你喜欢public,static也可以
      

  4.   

    Public 不可以嗎?
    我需要在外面訪問啊!
      

  5.   

    不是继承啊!A類包含B類還包含其它類.
    我是在定義B類的一個唯獨屬性時需要訪問A中公有變量.
      

  6.   

    邮很多种办法,比如在B定义一个A的实例属性private A _Parent;
    public A Parent ()
    {
      set{_Parent=value;}
      get{return _Parent;}
    }在A中
    public int D;
    B.Parent=this; B中使用D
    this.Parent.D和 Parent.D
      

  7.   

    B中使用D
    this.Parent.D或 _Parent.D
      

  8.   

    To access the top level variable in the nested classes architecture, must use Static to define the variables whole access by Sub Classes.