static void Main(string[] args) { SuperMan Clark = new SuperMan("Clark", 39); SpiderMan Peter = new SpiderMan(3, "Peter", 29); Flash gordon = new Flash(9, "Gordon", 31); ISuperHero[] SuperHeroes = new ISuperHero[] { Clark, Peter, gordon }; foreach (ISuperHero item in SuperHeroes) { ActiveHero(item); } }
static void GetMoreHeroData(ISuperHero hero) { SuperMan superman = hero as SuperMan; if (superman != null) { Console.WriteLine(superman.Speed); } SpiderMan Spider = hero as SpiderMan; if (Spider != null) { Console.WriteLine(Spider.WebLeft); } Flash Flashy = hero as Flash; Console.WriteLine(Flashy.Voltage); }