BelhardTraining.LessonIO.ConsoleMenu.AddItem C# (CSharp) Метод

AddItem() публичный Метод

public AddItem ( string text, System.Action itemCallback ) : void
text string
itemCallback System.Action
Результат void
        public void AddItem(string text, Action itemCallback)
        {
            if (_items.Count == 10) return;

            _items.Add(new MenuItem { Text = text, ItemCallback = itemCallback });
        }

Usage Example

Пример #1
0
        static void Main()
        {
            ConsoleMenu menu = new ConsoleMenu();
            menu.AddItem("Бинарная сериализация", BinarySerializationDemo);
            menu.AddItem("XML сериализация"     , XmlSerializationDemo);
            menu.AddItem("JSON сериализация"    , JsonSerializationDemo);
            menu.AddItem("Выход"                , null);

            do
            {
                menu.Show();
            } while (!menu.ExitSelected);
        }
ConsoleMenu