首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2013-02-24 
C# 一个小小的关于一个object的题。。。谢谢谁能帮我用一个简单的代码的例子说下 how an object sends a mess

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)

热点排行