我从reshaper收到以下错误:
“ WithEvents”变量只能作为具有类约束的类,接口或类型参数输入
这是一个代码示例:
Public Class MyClass(Of T As OtherClass)
Private WithEvents obj As T 'Error message'
Private Sub Obj_SomeEvent(sender As Object, e As EventArgs) Handles obj.SomeEvent
End Sub
End Class
如果我要使用某些接口并将泛型声明为类,则不会收到该错误。
Public Class MyClass(Of T As {ISomeInterface, Class})
Private WithEvents obj As T 'no error'
...
它仍然有效,所以我想知道这是我需要解决的问题还是可以安全地忽略该错误。