C# interface

Features of the interface:  

      1. Multiple inheritance interfaces and classes can inherit multiple interfaces

      2. Interface members cannot contain modifiers such as new, abstract, rewrite, etc.


 Simple application of the interface:

namespace interface_Demo
{
   class Program
  {
    static void Main(string[] agrs)
    {
      Appearance Name1=new Name1();
      Appearance Name2=new Name2();
      Name1.work("Beautiful");
      Name2.work("Handsome");
    }
  }
public interface Appearance{void face(string s);}
class Name1:
Appearance
{
  public void face(string s)
  {
    Console.WriteLine("我长得很"+s);
  }

}

public interface Appearance{void face(string s);}
class Name2:Appearance 
{
  public void face(string s)
  {
    Console.WriteLine("I look good"+s);
  }
}
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325212429&siteId=291194637
Recommended