❔ Can't use string interpolation within {}
I'm getting the error when I'm trying to use string interpolation within curly braces{}
string uname="abcd";
string pwd ="123";
string fullData= $"{"username": "{uname}","password": "{pwd}"}";
The above code throws an error.
I can do this with 2 or more lines. But I need in single line.
7 Replies
Double-up the braces you want to be literal
or use C# 11's new feature:
Or use JSON serializer
Not quite:
darn that's what I did but I undid it later
I suppose I forgot there are braces in json
😛
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.