public static void Menu(this FoodCollection <string> menu) { Console.WriteLine("OUR MENU"); for (int i = 0; i < menu.FoodAmount(); i++) { Console.WriteLine(menu.Meals[i]); } }
// Using "Clean code" rule // Исполнение лишь одной операции в функции private FoodCollection <string> addFoodToRation() { FoodCollection <string> ration = new FoodCollection <string>(); ration.AddDish(Racion.bread.ToString()); ration.AddDish((Racion.salt.ToString())); ration.AddDish(Racion.water.ToString()); return(ration); }
public void Ration() { FoodCollection <string> ration = addFoodToRation(); Action <int, string[]> action = delegate(int foodAmount, string [] meals) { for (int i = 0; i < foodAmount; i++) { Console.WriteLine(meals[i]); } }; action(ration.FoodAmount(), ration.Meals); }