How to escape a string in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = @"c# ""programming"" \language";

            s = Regex.Escape(s);

            Console.WriteLine(s);
        }
    }
}


/*
run:
  
c\#\ "programming"\ \\language
   
*/

 



answered Feb 7, 2017 by avibootz

Related questions

1 answer 163 views
1 answer 179 views
1 answer 192 views
1 answer 151 views
151 views asked Jun 6, 2021 by avibootz
1 answer 426 views
1 answer 138 views
...