I am a bit new to c#, and i am stuck at this point,
I have a regular string, where i made use of \
to escape "
, escape here means that to escape the compilers interpretation of "
, and get "
printed on the screen, and i get the expected output-->
class Program
{
static void Main(string[] args)
{
string s1 = "This is a \"regular\" string";
System.Console.WriteLine(s1);
System.Console.Read();
}
}
o/p--> This is a "regular" string
Now, i have a verbatim string, and i am trying to escape "
using \
in the same manner as above..-->
class Program
{
static void Main(string[] args)
{
string s2 = @"This is \t a \"verbatim\" string";//this would escape \t
System.Console.WriteLine(s2);
System.Console.Read();
}
}
Why the above isn't working ?
Answer
Use a double quote:
string s2 = @"This is \t a ""verbatim"" string";
No comments:
Post a Comment