What is this in VB? (from C#)

Posted on 2006-05-03
Medium Priority
Last Modified: 2010-04-23
Trying to write this correctly from C#

1)  public interface IMyPage { void MyPublicMethod(); }

public partial class MyPage : Page, IMyPage
public void MyPublicMethod() { ... }


Question by:born4code
  • 2
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 16602536
I'm not sure what Page is...are you inheriting from it or is it another Interface?

    Public Interface Page
        Sub MyPublicMethod()
    End Interface

    Public Interface IMyPage
        Sub MyPublicMethod()
    End Interface

    Partial Public Class MyPage
        Implements Page, IMyPage

        Public Sub MyPublicMethod1() Implements Page.MyPublicMethod

        End Sub

        Public Sub MyPublicMethod() Implements IMyPage.MyPublicMethod

        End Sub

    End Class

In VB you need to explicitly tell what method implements each piece of what Interface "contract".  As the example above shows, you can then easily handle it when two Interfaces have the same method name.

Not sure what you're doing in (3)...?

    Public Sub foo()
    End Sub

Expert Comment

ID: 16603517
Point 3 would be:

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16606769
You shouldn't need to do any casting to call "MyPublicMethod" though...

If the class "is a" IMyPage because it implements that Interface then you should just be able to call it without any casting no?

I think C# is pickier and you need all the casting to appease the compiler.  You may need to go such antics if Option Strict is On in VB.

Author Comment

ID: 16608966
Actually, the code is on different pages... i was lumping them.

It's good.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question