I've come across something in Interface implementation that I am not sure is
correct behavior in VB.NET (and maybe C#) or not?
Consider following example:
Public Interface IShape
Sub Draw()
End Interface
Public Class CCircle
Implements IShape
Public Sub DifferentDraw() Implements IShape.Draw
End Sub
End Class
According to OOP rules any CCircle object *IS-A* IShape object and also
IShape interface is a *CONTRACT* that guarantees all of its objects
implement methods in this contract. But in the following test, obj2 which is
supposed to obey above rules does not have access to Interface Draw()
method!!!???
Public Class Test
Public Sub Test()
Dim obj1 As IShape
obj1 = New CCircle
obj1.Draw()
Dim obj2 As CCircle
obj2 = New CCircle
obj2.DifferentD raw()
End Sub
End Class
Thanks
Masoud
correct behavior in VB.NET (and maybe C#) or not?
Consider following example:
Public Interface IShape
Sub Draw()
End Interface
Public Class CCircle
Implements IShape
Public Sub DifferentDraw() Implements IShape.Draw
End Sub
End Class
According to OOP rules any CCircle object *IS-A* IShape object and also
IShape interface is a *CONTRACT* that guarantees all of its objects
implement methods in this contract. But in the following test, obj2 which is
supposed to obey above rules does not have access to Interface Draw()
method!!!???
Public Class Test
Public Sub Test()
Dim obj1 As IShape
obj1 = New CCircle
obj1.Draw()
Dim obj2 As CCircle
obj2 = New CCircle
obj2.DifferentD raw()
End Sub
End Class
Thanks
Masoud
Comment