Search code examples
c#stringquotes

Is it possible to quote string with user input? c#


May I know if it's possible for me to do something like this?

string userInput = Console.ReadLine();
string strNewValue = "{ \"name\" : '" + userInput + "'}";

if yes, how can I do it?


Solution

  • I think you wanted this?

    string strNewValue = "{ \"name\" : \"" + userInput + "\"}";