接口C#中的可选空隙

use*_*473 1 c# plugins interface

您好我已经制作了一个看起来像这样的插件界面

 public  interface IPluginInterface :IEquatable<IPluginInterface>
{
    string Maker { get; }
    string Version { get; }  
    void Do();
    void Do_two();
}
Run Code Online (Sandbox Code Playgroud)

我试过,但还没有找到任何方法使字符串Maker和版本可选,我想我必须设置一个布尔值Equals,但不知道如何.谢谢你的帮助

Ode*_*ded 5

如果您在界面中声明它们,则必须实现它们.

您不能在接口上声明可选成员.

有几种选择:

  • 将界面分解为两个.只实现你需要的.
  • 实现一个抽象类,其中"可选"成员为空且非抽象.