|
關注:1
2013-05-23 12:21
求翻譯:Instead of = operator we should have used += operator to add a new delegate object to the delegate list. This would never happen in case of events. This is because we can perform only two operations on events, namely, += and -=. We cannot use = operator with events. As such, events provide a protection layer on delegat是什么意思?![]() ![]() Instead of = operator we should have used += operator to add a new delegate object to the delegate list. This would never happen in case of events. This is because we can perform only two operations on events, namely, += and -=. We cannot use = operator with events. As such, events provide a protection layer on delegat
問題補充: |
|
2013-05-23 12:21:38
=操作符而不是我們應該使用+ =操作符添加一個新的委托對象代表名單。這不會發生在事件的情況下。這是因為我們可以執行事件只有兩個操作,即+ =和-=.我們不能使用=運算符與事件。因此,事件對代表們提供了一個保護層。當我們使用+ =和-=操作符與代表,他們得到轉換成一個Delegate.Combine通話()和Delegate.Remove()方法。如果我們使用+ =和-=操作符,他們得到的事件調用轉換成add_c1()和remove_c1()方法。反過來,這些方法調用Delegate.Combine()和Delegate.Remove()方法。
|
|
2013-05-23 12:23:18
而我們應該使用的運算符=+運算符=以添加一個新的代表,代表對象名單。 這將永遠不會發生的事件的情況。 這是因為我們可以只執行兩個行動在事件,即+=和-=. 我們不能使用運算符=與事件。 這樣,活動提供一個保護層代表。 當我們使用+=和-=經營者與代表,他們得到轉變為一個呼吁delegate.combine()和代表.刪除()方法。
|
|
2013-05-23 12:24:58
|
|
2013-05-23 12:26:38
而不是 = 運算符,我們應該向委托列表中添加一
|
|
2013-05-23 12:28:18
|
湖北省互聯網違法和不良信息舉報平臺 | 網上有害信息舉報專區 | 電信詐騙舉報專區 | 涉歷史虛無主義有害信息舉報專區 | 涉企侵權舉報專區