谁能帮我用一个简单的代码的例子说下 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)