Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InterpolatedString with three braces

I have an interpolated string which ends with an argument followed by a closing brace. It needs to have a formatting argument, however the string is taking the first double brace as the escaped brace and remaining as the brace closing the argument:

> $"foo:{16:x}"
"foo:10"
> $"foo:{16:x}}}"
"foo:x}"

How to I correctly write the interpolated string so that I get foo:10}?

like image 772
BanksySan Avatar asked May 03 '26 18:05

BanksySan


1 Answers

There's no direct syntax for that, unfortunately;

$"foo:{16:x}{'}'}" // or $"foo:{16:x}{"}"}"

is a hack that'll work; otherwise, perhaps simply concatenate

like image 75
Marc Gravell Avatar answered May 06 '26 07:05

Marc Gravell