interface

class Program
    {
        public static void Main(string[] args)
        {
            test t = new test();
            test.Test(t);
            Console.WriteLine(t.Name);
            Console.ReadKey(true);
        }
    }
    interface Person{
        string Name{
            get;
        }
    
         void showName();
    }
    class test : Person{
        private string name = "小明";
        public string Name{
            get{
                return this.name;
            }
        }
        public static void Test(Person p){
            p.showName();
        }
        public void showName(){
            Console.WriteLine("output by method :  " + this.name);
        }
        
    }
原文地址:https://www.cnblogs.com/alplf123/p/7976171.html