-4

I want to place a double quotes inside a string but it seems I got an error. Someone can help me?

var User = user.Password;
string body = @"\" + User + ""\";
Amit Verma
  • 2,450
  • 2
  • 8
  • 21
  • 1
    You almost got it. But please search. This was asked over 10 years ago. – wazz Jun 20 '21 at 04:21
  • `@"""" + User + @""""` or `"\"" + User + "\""` or I prefer: `$"\"{User}\""` and of course this last `$@"""{User}"""`. –  Jun 20 '21 at 06:47
  • Does this answer your question ? [How to add double quotes to a string that is inside a variable?](https://stackoverflow.com/questions/3905946/how-to-add-double-quotes-to-a-string-that-is-inside-a-variable) and [Escape double quotes in a string](https://stackoverflow.com/questions/14480724/escape-double-quotes-in-a-string) –  Jun 20 '21 at 06:49

1 Answers1

2

For this you need to write below code.

var User = user.Password; 
string body = "\"" + User + "\"";
Amit Verma
  • 2,450
  • 2
  • 8
  • 21