Console.WriteLine("=== Задача 7 ===");
Console.Write("Введите предложение: ");
string sentence = Console.ReadLine();
Console.Write("Какое слово заменить? ");
string oldWord = Console.ReadLine();
Console.Write("На какое слово заменить? ");
string newWord = Console.ReadLine();
string newSentence = sentence.Replace(oldWord, newWord);
Console.WriteLine($"Результат: {newSentence}");
Console.WriteLine();
// === Задача 8 ===
// Подсчет символов (без пробелов)
Console.WriteLine("=== Задача 8 ===");
Console.Write("Введите строку: ");
string inputStr = Console.ReadLine();
int charCount = inputStr.Replace(" ", "").Length;
Console.WriteLine($"Количество символов (без пробелов): {charCount}");
Console.WriteLine();
// === Задача 9 ===
// Сравнение двух строк без учета регистра
Console.WriteLine("=== Задача 9 ===");
Console.Write("Введите первую строку: ");
string str1 = Console.ReadLine();
Console.Write("Введите вторую строку: ");
string str2 = Console.ReadLine();
bool areEqual = string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase);
if (areEqual)
Console.WriteLine("Строки одинаковы (без учета регистра)");
else
Console.WriteLine("Строки различаются");
Console.WriteLine();
// === Задача 10 ===
// Преобразование регистра
Console.WriteLine("=== Задача 10 ===");
Console.Write("Введите строку: ");
string mixed = Console.ReadLine();
Console.WriteLine($"В верхнем регистре: {mixed.ToUpper()}");
Console.WriteLine($"В нижнем регистре: {mixed.ToLower()}");