Interface problem

J

John

Hi

I have implemented an interface as below. I am getting a "Class
'HelloWordPlugin' must implement 'Sub PerformAction()' for interface
'IPlugin'." error. What is the problem and how can I fix it?

Thanks

Regards


Public Interface IPlugin
Sub PerformAction()
End Interface

Public Class HelloWordPlugin
Implements IPlugin

Public Sub PerformAction()
Console.WriteLine("Hello, World!")
End Sub
End Class
 
A

_AnonCoward

: Hi
:
: I have implemented an interface as below. I am getting a
: "Class 'HelloWordPlugin' must implement 'Sub PerformAction()'
: for interface 'IPlugin'." error. What is the problem and how
: can I fix it?
:
: Thanks
:
: Regards
:
:
: Public Interface IPlugin
: Sub PerformAction()
: End Interface
:
: Public Class HelloWordPlugin
: Implements IPlugin
:
: Public Sub PerformAction()
: Console.WriteLine("Hello, World!")
: End Sub
: End Class



'-----------------------------------------------------------------------
Public Interface IPlugin
Sub PerformAction()
End Interface

Public Class HelloWordPlugin
Implements IPlugin

Public Sub PerformAction() Implements IPlugin.PerformAction
Console.WriteLine("Hello, World!")
End Sub
End Class
'-----------------------------------------------------------------------
 
A

Armin Zingler

John said:
Hi

I have implemented an interface as below. I am getting a "Class
'HelloWordPlugin' must implement 'Sub PerformAction()' for interface
'IPlugin'." error. What is the problem and how can I fix it?

Thanks

Regards


Public Interface IPlugin
Sub PerformAction()
End Interface

Public Class HelloWordPlugin
Implements IPlugin

Public Sub PerformAction()
Console.WriteLine("Hello, World!")
End Sub
End Class



http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconInterfaces.asp

Same available via <F1>


Armin
 
H

Herfried K. Wagner [MVP]

John said:
I have implemented an interface as below. I am getting a "Class
'HelloWordPlugin' must implement 'Sub PerformAction()' for interface
'IPlugin'." error. What is the problem and how can I fix it?

VB.NET doesn't determine which method in a class implementing an interface
implements a certain method of the interface by comparing the methods'
names. Instead, you will have to declaratively specify which method of the
interface the method implements.
Public Interface IPlugin
Sub PerformAction()
End Interface

Public Class HelloWordPlugin
Implements IPlugin

Public Sub PerformAction()
Console.WriteLine("Hello, World!")
End Sub
End Class

\\\
Public Class HelloWorldPlugin
Implements IPlugin

Public Sub PerformAction() Implements IPlugin.PerformAction
...
End Sub
End Class
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top