How to remove text in brackets from a string in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = "c# vb.net (c c++)";

            int n;
            var output = s.Substring(n = 1 + s.IndexOf('('), s.IndexOf(')') - n);

            Console.WriteLine(output);
        }
    }
}


/*
run:
    
c c++

*/

 



answered Sep 15, 2017 by avibootz
...