W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
using System;
​
namespace MyApplication
{
  interface IFirstInterface
  {
    void myMethod(); // 接口方法
  }
​
  interface ISecondInterface
  {
    void myOtherMethod(); // 接口方法
  }
​
  // 实现多个接口
  class DemoClass : IFirstInterface, ISecondInterface
  {
    public void myMethod()
    {
      Console.WriteLine("Some text...");
    }
    public void myOtherMethod()
    {
      Console.WriteLine("Some other text...");
    }
  }
​
  class Program
  {
    static void Main(string[] args)
    {
      DemoClass myObj = new DemoClass(); // 创建一个 DemoClass 对象
      myObj.myMethod(); // 调用 myMethod() 方法
      myObj.myOtherMethod(); // 调用 myOtherMethod() 方法
    }
  }
}