✅ Simple string formatting
Why am I not able to do formatting for this specific string? What is the right way?
9 Replies
Yes I know the dollar sign goes before the quotation but It doesn't fix it
1) you're redeclaring
jsonPayload
3 times which isn't valid
2) you're putting parentheses around your interpolated string like $("something")
which is also wrong, no parentheses are neededI know, I just drew that up to illustrate
Even if I put the dollar sign a step to the right it still gives an error
"an error"
and did you remove the parentheses?
Yes I did, I don't see a mismatch of bracers or a misuse of backslash
did you check the documentation for string interpolation? https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
$ - string interpolation - format string output
String interpolation using the
$
token provides a more readable and convenient syntax to format string output than traditional string composite formatting.Yes I looked at a few internet guides, and i tried multiple ways of doing it, one brace or three
you skipped over the one it tells you to use if you want to include a literal curly brace
which is 2
Ah thank you, that means the bracers need to be two, three then four
$"{{"type":"page","body":{{"storage":{{"value":"<p>{{{a}}}</p>"}}}}";
Tricky stuff, thank you for helping me even when I was being vague