![](/img/trans.png)
[英]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.