-
-
Save conanak99/24dbd016a8258af5dc49f3fc051b93f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Bird { | |
public virtual void Fly() { Console.Write("Fly"); } | |
} | |
public class Eagle : Bird { | |
public override void Fly() { Console.Write("Eagle Fly"); } | |
} | |
public class Duck : Bird { | |
public override void Fly() { Console.Write("Duck Fly"); } | |
} | |
public class Penguin : Bird { | |
public override void Fly() { throw new NoFlyException(); } | |
} | |
var birds = new List { new Bird(), new Eagle(), new Duck(), new Penguin() }; | |
foreach(var bird in birds) bird.Fly(); | |
// Tới pengiun thì lỗi vì cánh cụt quăng Exception |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment