日期:2014-05-17  浏览次数:20936 次

求解释,关于events的两句英文
在学习events,看到了两句英文,不知道是什么含义,请大家指点。谢谢

Events are properties of the class publishing the event.

The keyword event controls how the event property is accessed by the subscribing classes.

------解决方案--------------------
Google出的不对
Events are properties of the class publishing the event.
要发布的这个事件,是类的属性

The keyword event controls how the event property is accessed by the subscribing classes.
关键事件控制的事件属性是如何被引用类访问。
------解决方案--------------------
Events are properties of the class publishing the event.
Event是类发布的事件类型的属性。
The keyword event controls how the event property is accessed by the subscribing classes.
event关键字控制事件属性如何被订阅的类访问。

简单来说是这个意思。属性你明白么,比如
private int x;
public int X { get { return x; } set { x = value; } }
这里属性访问器X控制外部调用者如何访问私有字段x的方式。

那么事件是这样的特殊的属性
private event EventHandler click;
public event EventHandler Click
{
    add { click += value; } remove { click -= value; }
}
click是一个属性成员,你可以使用Click去控制如何添加/删除一个来自订阅者的事件处理。
------解决方案--------------------
如果你从.net的角度,那么event是event,proproty是property,它们不是一类东西。因为具体的语言的设计是比较细致的(甚至是不一致的)。

但是如果你从面向对象设计角度,一个对象封装不过是“类名、属性、方法”三个东西,于是它把事件定义归入属性,以便于进一步理解在设计中的关系。

要理解自然语言、背景知识是需要一些经验的。