Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a string with Quotes in it in C#

C# newbie here. I am trying to set a C# variable as follows.

string profileArg = @"/profile ""eScore"" ";

The end result is that I want the variable to contain the value

/profile "eScore" 

There should be a space in the string after the "eScore"

How do I do it?

Seth

like image 581
Seth Spearman Avatar asked Sep 01 '10 19:09

Seth Spearman


1 Answers

You have a space after eScore in your string.

// a space after "eScore"
string profileArg = @"/profile ""eScore"" ";

// no space after "eScore"
string profileArg = @"/profile ""eScore""";

// space in "eScore "
string profileArg = @"/profile ""eScore """;

// No space using escaping
string profileArg = "/profile \"eScore\"";
like image 147
jgauffin Avatar answered Oct 05 '22 07:10

jgauffin