[英]Why can I pass the wrong interface to a function without compiler errors?
[英]Why this sub is valid? Why i can pass each Type (String, Interface, Int) to a sub without compiler error as parameter
Public Class MainWindow
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
Me.x(1)
End Sub
Public Sub x(ByVal x As String)
MessageBox.Show(x)
End Sub
End Class
如果我希望在sub x中有一个接口,例如Public sub x(Byval IPerson)
它也可以接受每种类型而不会出现错误。
在VS2013中,在“调试/调试/项目和解决方案/ VB默认值”下,是一个选项,用于将“严格选项”设置为打开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.