Загрузка данных


using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<string> notes = new List<string>();
        notes.Add("Купить молоко");
        notes.Add("Позвонить маме");

        Console.WriteLine("Моя записная книжка");
        Console.WriteLine("Для справки введите h");

        char cmd = 'h';

        while (cmd != 'q')
        {
            if (cmd == 'h')
            {
                Console.WriteLine("\nКоманды:");
                Console.WriteLine("1 - показать записи");
                Console.WriteLine("a - добавить");
                Console.WriteLine("d - удалить");
                Console.WriteLine("f - найти запись");
                Console.WriteLine("h - справка");
                Console.WriteLine("q - выход");
            }
            else if (cmd == '1')
            {
                Console.WriteLine("\nВаши записи:");
                if (notes.Count == 0)
                {
                    Console.WriteLine("Пусто");
                }
                else
                {
                    for (int i = 0; i < notes.Count; i++)
                    {
                        Console.WriteLine((i + 1) + ". " + notes[i]);
                    }
                }
            }
            else if (cmd == 'a')
            {
                Console.Write("\nВведите запись: ");
                string text = Console.ReadLine();
                notes.Add(text);
                Console.WriteLine("Добавлено");
            }
            else if (cmd == 'd')
            {
                Console.Write("\nНомер для удаления: ");
                string numText = Console.ReadLine();
                if (int.TryParse(numText, out int num) && num > 0 && num <= notes.Count)
                {
                    notes.RemoveAt(num - 1);
                    Console.WriteLine("Удалено");
                }
                else
                {
                    Console.WriteLine("Ошибка");
                }
            }
            else if (cmd == 'f')
            {
                Console.Write("\nЧто ищем: ");
                string find = Console.ReadLine().ToLower();
                bool found = false;

                for (int i = 0; i < notes.Count; i++)
                {
                    if (notes[i].ToLower().Contains(find))
                    {
                        Console.WriteLine((i + 1) + ". " + notes[i]);
                        found = true;
                    }
                }

                if (!found)
                {
                    Console.WriteLine("Не найдено");
                }
            }
            else
            {
                Console.WriteLine("Неизвестная команда");
            }

            Console.Write("\n> ");
            cmd = Console.ReadKey().KeyChar;
            Console.WriteLine();
        }

        Console.WriteLine("Выход");
    }
}