Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
Public Class EntryPoint Shared Sub Main() Dim m As New Mouse Dim s As New Shark DoSomethingWith(m) DoSomethingWith(s) End Sub ' Client code Public Shared Sub DoSomethingWith(ByVal a As Animal) a.Bite() End SubEnd ClassPublic MustInherit Class Animal Public MustOverride Sub Bite()End ClassPublic Class Mouse Inherits Animal Public Overrides Sub Bite() MsgBox("Disease") End SubEnd ClassPublic Class Shark Inherits Animal Public Overrides Sub Bite() MsgBox("ouch!") End SubEnd Class
Sub Main() Dim m As New Mouse Dim s As New Shark DoSomethingWith m DoSomethingWith sEnd Sub' Client codeSub DoSomethingWith(ByVal a As Animal) a.BiteEnd Sub
Public Sub Bite()End Sub
Implements AnimalPrivate Sub Animal_Bite() MsgBox "Disease"End Sub
Implements AnimalPrivate Sub Animal_Bite() MsgBox "ouch!"End Sub