public class BankAccount
    {
        
        Emailer emailer;  
        Mobile phoneNumber;  
 
                 private double _money;        public Emailer Emailer
        {
            get { return emailer; }
            set { this.emailer = value; }
        }
        public Mobile PhoneNumber
        {
            get { return phoneNumber; }
            set { this.phoneNumber = value; }
        }
        public double Money
        {
            get { return _money; }
            set { this._money = value; }
        }        public void WithDraw()
        {
            emailer.SendEmail(this);
            phoneNumber.SendNotification(this);
        }
    }

红色的地方代表什么意思?
又不是类又不是方法``字段也不像?
大家给我个直观的``

解决方案 »

  1.   

            Emailer emailer;  
            Mobile phoneNumber;  
    只是去掉了private 吗  两个类 声明了两个对象
      

  2.   

    一个类型 的定义 public class  aa
    {
     private name="";
    public string Name
    {
      set{}
       get{}
    }
    } public class  bb{
       aa  example
    //......
    }
      

  3.   

    Emailer,Mobile 是从别的类库中引用进来的吧.可能是 类 接口 结构 枚举
    Emailer emailer;  
            Mobile phoneNumber;  就是声明变量
      

  4.   

    看来一楼的  呵呵 不一定是类你把鼠标放到  Emailer 和 Mobile  上不就知道他是什么了  struct ,class,enum,interface
      

  5.   

    可能是这里的 某一种吧,看看
        Emailer emailer;  
        Mobile phoneNumber;  
    红字在程序里定义的是什么,那就是什么了!
      

  6.   

    字段怎么会没有类名呢……public class MyClass
    {
        string str;//这就是一个私有字段,它是string类的
    }没有类型你怎么声明字段……
      

  7.   

    public class BankAccount 
        { 
          
            Emailer emailer;  
            Mobile phoneNumber;  
                    private double _money;         public Emailer Emailer 
            { 
                get { return emailer; } 
                set { this.emailer = value; } 
            } 
            public Mobile PhoneNumber 
            { 
                get { return phoneNumber; } 
                set { this.phoneNumber = value; } 
            } 
            public double Money 
            { 
                get { return _money; } 
                set { this._money = value; } 
            }         public void WithDraw() 
            { 
                emailer.SendEmail(this); 
                phoneNumber.SendNotification(this); 
            } 
        } 
    红色的地方代表什么意思? 
    又不是类又不是方法``字段也不像? 
    大家给我个直观的`` 
    -----------------------------
    我知道了,是类因为我下面定义了这2个类;但问题来了,为什么在这又写了这2个类,而且写法是这样饿。我在教材上面从来都没看到过?
    请大家给我上一课吧``
      

  8.   

    下面定义的那两个是属性,不是类.. Emailer Mobile应该是在其他地方定义的类或结构..
    红字部分是字段定义.
      

  9.   

    public class BankAccount 
        { 
          
            Emailer emailer;  
            Mobile phoneNumber;  
                    private double _money;         public Emailer Emailer 
            { 
                get { return emailer; } 
                set { this.emailer = value; } 
            } 
            public Mobile PhoneNumber 
            { 
                get { return phoneNumber; } 
                set { this.phoneNumber = value; } 
            } 
            public double Money 
            { 
                get { return _money; } 
                set { this._money = value; } 
            }         public void WithDraw() 
            { 
                emailer.SendEmail(this); 
                phoneNumber.SendNotification(this); 
            } 
        } 同学好:既然你自己已经  声明了这两个类 并且对它进行了封装!封装是为了给其中的成员变量赋予属性 并且在下面进行调用!怎么来调用  就是Emailer emailer;  
            Mobile phoneNumber; 
    建立实例 就是建立对象 来掉调用  你所封装的字段 的属性!
    不知道 我这么说你明白吗?