What is this in VB? (from C#)

Posted on 2006-05-03
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
    LVL 85

    Accepted Solution

    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

    Point 3 would be:

    LVL 85

    Expert Comment

    by:Mike Tomlinson
    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.
    LVL 2

    Author Comment

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

    It's good.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now