using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace useInterface { interface IMovable { float speed{get;} float MaxSpeed { get; set; } void run(); void walk(); void fly(); } class Person:IMovable { private int _MaxSpeed; public float speed { get { return 20.5f; } } public float MaxSpeed { get { return this._MaxSpeed; } set { this._MaxSpeed = (int)value; } } public void run() { System.Console.WriteLine("Person.Run():A person is running!"); } public void walk() { System.Console.WriteLine("Person.walk():A person is walking!"); } public void fly() { System.Console.WriteLine("Person.fly():A person flies with a plane!"); } } class Program { static void Main(string[] args) { Person a = new Person(); a.MaxSpeed = 50; sthMove(a); } static void sthMove(IMovable mov) { string ty = mov.GetType().Name; System.Console.WriteLine("This is a {0}",ty); System.Console.WriteLine("{0}.Speed={1}", ty,mov.speed); System.Console.WriteLine("{0}.MaxSpeed={1}", ty, mov.MaxSpeed); mov.walk(); mov.run(); mov.fly(); System.Console.ReadLine(); } } }