static void Main(string[] args) { FruitSalad firstSalad = new FruitSalad { fruits = new Fruit[] { new Apple { _calories = 50, }, new Mango { _calories = 80, }, new Grape { _calories = 65 }, new Banana { _calories = 25, } } }; Apple apple = new Apple { color = "red" }; PrintAppleColor(apple); Banana banana = new Banana { size = 15.2f }; PrintBananaSize(banana); PrintCalories(firstSalad); PrintFavorite(firstSalad); }
static void PrintAppleColor(Apple a) { Console.WriteLine(a.color); }