当前位置: 代码迷 >> C# >> C# 一个小小的关于一个object的题。多谢
  详细解决方案

C# 一个小小的关于一个object的题。多谢

热度:6331   发布时间:2013-02-25 00:00:00.0
C# 一个小小的关于一个object的题。。。谢谢
谁能帮我用一个简单的代码的例子说下 how an object sends a message to an object of another
class and how the receiving object responds to the message
题目可能有点幼稚了。

平时学习的时候应该经常这么用,但是反过来一问,就有点迷糊了。。。

谢谢了。。

------解决方案--------------------------------------------------------
这句话的意思很宽泛,任何一种两个类之间的依赖都可以用这句话来表示。比如最简单的方法调用。


    public class A
    {
        private B _b = new B();

        public void MethodA()
        {
            string value = this._b.MethodB();
        }
    }

    public class B
    {
        public string MethodB()
        {
            return string.Empty;
        }
    }


an object(A) sends a message(MethodB) to an object of another class(B) and the receiving object(B) responds to the message(string)
  相关解决方案