How to remove a substring from a given string in C#

1 Answer

0 votes
using System;

public class Program
{
    public static void Main(string[] args)
    {
        string str = "Java C C++ Monty Python C#";
        string substr = "Monty ";

        str = str.Replace(substr, "");

        Console.WriteLine(str);
    }
}


 
/*
run:
   
Java C C++ Python C#
   
*/

 



answered Jun 5, 2024 by avibootz

Related questions

...