0

I have the following class in C#:

public class SyncListener : SyncStatusListener
{ ... }

and I want to convert it to VB.NET which I think would look like this:

Public Class SyncListener
    Inherits SyncStatusListener
    ...
End Class

but here comes the question: SyncStatusListener is an interface and VB.NET does not allow inherit from interfaces. How can I convert the C# code to VB.NET in this case?

Thank you in advance!

4 Answers 4

4

Use the Implements statement instead.

If a class or structure implements one or more interfaces, it must include the Implements statement immediately after the Class or Structure statement. The Implements statement requires a comma-separated list of interfaces to be implemented by a class. The class or structure must implement all interface members using the Implements keyword.

So change your code to:

Public Class SyncListener
    Implements SyncStatusListener
    ...
End Class
Sign up to request clarification or add additional context in comments.

1 Comment

It might be helpful to elaborate on your last sentence, showing the equivalents of implicit and explicit interface implementations.
1

For VB.Net you use the implements keyword, not inherits. See here. Implements

Comments

1

Use Implements

Public Class SyncListener
    Implements SyncStatusListener
    ...
End Class

Comments

0

In C# for Interface implementation is done by a :. But VB.Net have reserved a keyword for this.

Keyword for Interface implementation is Implements

You can implement multiple Interface in two ways.

One is Use Implements keyword for each Interface

Public Class Test
     Implements Interface1
     Implements Interface2

End Class

another one method is to use a comma -seperater like below

Public Class Test
    Implements Interface1, Interface2

End Class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.