Created
March 22, 2016 13:10
-
-
Save micmaher/6ee8ba6f39708a9f135e to your computer and use it in GitHub Desktop.
.NET Framework formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a = 348 | |
"{0:N2}" -f $a # Numeric to 2 decimal places = 348.00 | |
"{0:D8}" -f $a # Decimal 8 places = 00000348 | |
"{0:C2}" -f $a # Currency to two places = €348.00 | |
"{0:P0}" -f $a # Percentage x 100 = 34,800 % | |
"{0:X0}" -f $a # Hex = 15C | |
# First number represents the index number of the item to be formatted. | |
# In this example we take teh second number in the array $a | |
$a=19385790464, 6786868768 | |
"{1:N0}" -f $a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I seen PowerShell MVP Trevor Sullivan use this weird code in a demo and it had me intrigued. I had to find how it worked
"{0:N2}" -f $a