Нужно сделать в C#
Даны строки S и S0. Удалить из строки S все подстроки, совпадающие с S0. Если совпадающих подстрок нет, то вывести строку S без изменений
Ответы
using System;
namespace task30248648
{
class MainClass
{
public static void Main(string[] args)
{
string S = "Hello world, Hello world, Hello world, Hello world";
string SO = "llo";
Console.WriteLine(S.Replace(SO, ""));
}
}
}
Код
using System;
using System.Text; // Лучше всего для работы со строками использовать StringBuilder
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.Write("Введите 1-ю строку: ");
StringBuilder s = new StringBuilder(Console.ReadLine());
Console.Write("Введите 2-ю строку: ");
string s0 = Console.ReadLine();
s.Replace(s0, null);
Console.WriteLine("\n" + s);
Console.ReadKey();
}
}
}
Пример
[Скриншот]