在C#中,您可以在订阅/取消订阅事件时定义显式添加/删除代码. 这可能在VB.net中吗? Imports System.Runtime.CompilerServices... Private propchanged As PropertyChangedEventHandler Public Custom Event PropertyChanged
这可能在VB.net中吗?
Imports System.Runtime.CompilerServices ... Private propchanged As PropertyChangedEventHandler Public Custom Event PropertyChanged As PropertyChangedEventHandler <MethodImpl(MethodImplOptions.Synchronized)> _ AddHandler(ByVal value As PropertyChangedEventHandler) propchanged = DirectCast([Delegate].Combine(propchanged, value), PropertyChangedEventHandler) End AddHandler <MethodImpl(MethodImplOptions.Synchronized)> _ RemoveHandler(ByVal value As PropertyChangedEventHandler) propchanged = DirectCast([Delegate].Remove(propchanged, value), PropertyChangedEventHandler) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Dim handler = propchanged If handler IsNot Nothing Then handler(sender, e) End RaiseEvent End Event