I'm going through a
VB.NET book at the moment and I've come to a part about Interfaces. The book defines an Interface as follows:
Publice Interface IDriveable
Sub GoForward(ByVal Speed As Integer)
Sub Halt()
Function DistanceTraveled() as Integer()
End Interface
It then goes on to show a normal use with:
Implements IDriveable
However it then shows under the title of "Polymorphism with Interfaces" the following:
Public Sub GoSomewhere(ByVal As IDriveable)
' implementation omitted
End Sub
Anthis is where I get stuck how whould you implement an Interface when its pasted as a parameter. I tried defining it as:
Dim x as IDriveable
x.FuelLevel = 10
And that produced a runtime error of 'SystemNullReferenceException'. I then tried to define it as:
Dim x = new IDriveable
That gave a design time error of not being able to use new with an Interface.
Any ideas?
But that gives a runtime error