2021-05-31

Late Binding: Expecting error but not getting it

I wrote the below code to understand Late Binding with Option Strict ON. With OPTION STRICT ON, I was expecting an error in the statement: o = New Car(). But not getting any error. Isn't that strange? Its clearly mentioned in the MSDN documentation on Option Strict that when ON it prevents late binding - gives a compile time error. So what is happening here....can someone pls help?

Option Strict On
Module Module1
    Sub Main()
        Dim o As Object
        o = New Car() 'Expecting error here but not getting
        Console.ReadLine()
    End Sub
End Module

Class Car
    Public Property Make As String
    Public Property price As Integer
End Class


from Recent Questions - Stack Overflow https://ift.tt/2SBiSud
https://ift.tt/eA8V8J

No comments:

Post a Comment