C
C#11mo ago
Caeden

Combine string formatting (eg `$"{number:N2}" with D2) so like `{number:N2D2}`)

You have string interpolation like $"{number:N2}", how can I combine formats? Like $"{number:N2D2}"
8 Replies
Caeden
CaedenOP11mo ago
this doesn't work, nor does number:N2:D2, and I couldn't find it here https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings
Standard numeric format strings - .NET
In this article, learn to use standard numeric format strings to format common numeric types into text representations in .NET.
canton7
canton711mo ago
What are you trying to do? Those are two separate things
Caeden
CaedenOP11mo ago
I want to pad a float left and right So 3.7 becomes 03.70 D2 does like pad left and N does pad right as far as I am aware from what it says here
canton7
canton711mo ago
Custom numeric format strings - .NET
Learn how to create a custom numeric format string to format numeric data in .NET. A custom numeric format string has one or more custom numeric specifiers.
Angius
Angius11mo ago
00.00 would be the format, wouldn't it?
MODiX
MODiX11mo ago
Angius
REPL Result: Success
var x = 3.7; $"{x:00.00}"
var x = 3.7; $"{x:00.00}"
Result: string
03.70
03.70
Compile: 369.286ms | Execution: 29.070ms | React with ❌ to remove this embed.
Angius
Angius11mo ago
ye
Caeden
CaedenOP11mo ago
Thanks Thanks as well
Want results from more Discord servers?
Add your server