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


Console.WriteLine("Введите предложение:");
        string sentence = Console.ReadLine();

        // Случай 1: известно, что запятые есть
        Console.WriteLine("\nСлучай 1 (известно, что запятые есть):");
        int commaIndex = sentence.IndexOf(',');
        if (commaIndex != -1)
        {
            string beforeComma = sentence.Substring(0, commaIndex);
            Console.WriteLine("Символы до первой запятой: " + beforeComma);
        }

        // Случай 2: запятых может не быть
        Console.WriteLine("\nСлучай 2 (запятых может не быть):");
        int commaIndex2 = sentence.IndexOf(',');
        if (commaIndex2 != -1)
        {
            string beforeComma = sentence.Substring(0, commaIndex2);
            Console.WriteLine("Символы до первой запятой: " + beforeComma);
        }
        else
        {
            Console.WriteLine("В предложении нет запятых.");
        }