E
Earthlink
This is best explained by looking at the comments in the sample code below.
Is this a VB.NET bug?
Option Strict On
Public Class Class1
End Class
Public Class Class2 : Inherits Class1
Public Sub bar()
Dim c3 As New Class3
Dim c2 As Class2
c3.foo(c2) '*** Compiler Error: Option Strict On disallows implicit
conversions from 'ClassLibrary1.Class1' to 'ClassLibrary1.Class2'
c3.foo(Me) 'However, this is OK even though Me is an instance of
Class 2
c3.foo(CType(c2, Class2)) '?? This also OK, even though I am also
passing in an instance of Class 2
Dim c1 As Class1
c3.foo(c1) 'This is OK - no surprise
End Sub
End Class
Public Class Class3
Public Sub foo(ByRef arg1 As Class1)
End Sub
End Class
Is this a VB.NET bug?
Option Strict On
Public Class Class1
End Class
Public Class Class2 : Inherits Class1
Public Sub bar()
Dim c3 As New Class3
Dim c2 As Class2
c3.foo(c2) '*** Compiler Error: Option Strict On disallows implicit
conversions from 'ClassLibrary1.Class1' to 'ClassLibrary1.Class2'
c3.foo(Me) 'However, this is OK even though Me is an instance of
Class 2
c3.foo(CType(c2, Class2)) '?? This also OK, even though I am also
passing in an instance of Class 2
Dim c1 As Class1
c3.foo(c1) 'This is OK - no surprise
End Sub
End Class
Public Class Class3
Public Sub foo(ByRef arg1 As Class1)
End Sub
End Class