using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace day06 { public class Fu { public virtual void Cut() { Console.WriteLine("父类"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace day06 { public class Zi1:Fu { public override void Cut() { Console.WriteLine("理发师"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace day06 { class Program { static void Main(string[] args) { List<Fu> list = new List<Fu>() { new Zi1(), }; foreach (Fu person in list) { person.Cut(); } Console.ReadKey(); } } }