How to use multiple replacements to replace every instance of a word in a string with C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main()
        {
            string s = "yes no yes yes no no yes";
 
            s = s.Replace("yes", "maybe");

            Console.WriteLine(s);
        }
    }
}


/*
run:
    
maybe no maybe maybe no no maybe
  
*/

 



answered Aug 26, 2018 by avibootz
...