using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication17 { abstract class fruit//建立一个抽象类 abstriact { public abstract void GrowInarea();//抽象方法 } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication17 { class apple : fruit//可以理解为水果中的苹果 { public override void GrowInarea() { Console.WriteLine("南方北方都可以种我。"); } } class pineapple : fruit//可以理解为水果中的菠萝 { public override void GrowInarea() { Console.WriteLine("我喜欢温暖,只能在南方见到我"); } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication17 { class Program { static void Main(string[] args) { fruit f; f = new apple();//实例化 f.GrowInarea(); f = new pineapple(); f.GrowInarea(); Console.ReadLine(); } } }