Interface implementation in C# and VB.NET

后端 未结 3 1776
青春惊慌失措
青春惊慌失措 2020-12-21 23:21

I have an interface defined in C# project:

public interface IForm
{
    bool IsDisposed { get; }
    void Show();
}

I implemen

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 00:02

    VB.NET allows you to name a function/sub differently than the function/sub that it implements. This means that you must explicitly add the Implements to the end of the signature.

    In C# you can't do this, so the implementations "just work" without you having to add anything.

    MSDN:

    The parameter types and return types of the implementing member must match the interface property or member declaration in the interface. The most common way to implement an element of an interface is with a member that has the same name as the interface

提交回复
热议问题