- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Remember Remember
- Named And
- It's About Time
- Scrollpocalypse
- Fast Quick
- 12345
- Said Different
- Ai Dios Mio
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
TRWTF is not allowing
"#0.## \u2030"like in Java.Admin
This looks like they're trying to set-up an interpolated string (i.e.: $"{0:#,##0.00;(#,##0.00)}", which would just result in "0.00;(0.00)"). But as far as I know, you can't use interpolated strings like this:
But maybe this isn't C#, and it works just fine in whatever language they're using.
Admin
If you're typing it frequently, you can use Option+Shift+R to type ‰ on macOS. But let's be honest, 99.999% of people (or 999.99‰ of people?) aren't typing it frequently and are going to have to google it, like I did just now.
Admin
It's probably C# and I doubt they're trying to use the $ syntax. IMO more likely it's like this:
And you're correct about the $ syntax. MSFT says only works with a literal string. It's a compile-time transformation into formatting calls. See the first sentence here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
Admin
Agreed, your answer is most likely correct. I forgot that string.Format also allows formatting after its placeholders. If I use string.Format at all, I usually just use the basic placeholders (e.g.: "{0} - {1}") and rarely need any specific formats, and when I do I usually put the formatting with the arguments. E.g.: string.Format("Today: {0}", DateTime.Now.ToString("yyyy-MM-dd"));
Admin
The designers of C
printfrealized long ago that you sometimes need to parameterize some of the formatting options, so you can use*in place of things like the field width to get the value from the arguments. This doesn't handle all the cases where you need to build format strings dynamically, but it gets the most common ones.Admin
Funnily enough, in C++ 20 vformat can be used with formatting passed in as variable.
Admin
To be fair, that format specifier is just useful for Dungeon & Dragons campaigns anyway. Every civilized country on this planet is using metric for ages now :-).
Admin
Yeah, there's actually a lot more to string interpolation in C#. It also uses best-performance string operations and even StringBuilder when appropriate. They could go full in with optimizations since there was no backwards compatibility holding them back.
The nice thing is you can even build format strings and then cache them to use them for string operations that expect format strings. Super useful for code generators and to basically use the $ operator to do stuff like escape SQL properly with minimum overhead directly in the command like shown here: https://learn.microsoft.com/en-us/ef/core/querying/sql-queries?tabs=sqlserver.
Admin
wait, there's a format string around since .Net 1.1 that I don't know about ?
Admin
string.Format is around since the beta, so pre-net 1.0, the current extended version with additional support for stuff like CultureInfo.InvariantFormat is around since 1.1 (because that itself was introduced with 1.1). Only interpolation is new since .net core cause a lot of developers are just too sloppy to use the correct composition methods in the right context.
Addendum 2026-10-23 05:47: Plus I have to add there was a major change how .net handles strings internally between v1.x and v2.0 which had major implications regarding StringBuilder usage, so it's not only sloppiness but also incompetence caused by poorly communicated changes by MS that made interpolation well. You just have to ask a dev when strings will be interned and you'd be surprised how much nonsense and outdated information you will be faced with.
Admin
It is allowed. Not sure why the example uses concatenation instead...
Admin
option shift r gives me this: Â, on my Mac with a British English keyboard. After a bit of research involving keyboard viewer, I have discovered it is option shift e. If you have a different keyboard YKMMV
Admin
Based on some rumors from Claude, the next iteration of dotNet will require spending a bitcoin to use any US date format...
Admin
WinCompose, so I can type ‰ by CAPSLOCK (my compose key) % o.