How to replace spaces in a string with an underscore in C#

1 Answer

0 votes
using System;

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

            s = s.Replace(" ", "_");
            Console.WriteLine(s);
        }
    }
}


/*
run:
    
c#_c___c++_________java

*/

 



answered Jul 12, 2017 by avibootz
...