Wednesday, 17 April 2013

Show-NumberDecimalSeparator.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script demonstrates the use of the NumberDecimalSeparator
  4. .DESCRIPTION 
  5.     This script is a re-write of an MSDN sample, using PowerShell 
  6. .NOTES 
  7.     File Name  : Show-NumberDecimaleparatort.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 3.0 
  10. .LINK 
  11.     This script posted to: 
  12.         http://www.pshscripts.blogspot.com 
  13.     MSDN sample posted to: 
  14.          http://msdn.microsoft.com/en-us/library/b74zyt45%28v=vs.100%29.aspx 
  15. .EXAMPLE 
  16.     PSH> .\Show-NumberDecimalSeparator.ps1 
  17.     123,456,789.00 
  18.     123,456,789 00 
  19. #> 
  20.  
  21. # Get Number Format 
  22. $nf  = New-Object System.Globalization.CultureInfo  "en-US", $False  
  23. $nfi = $nf.NumberFormat 
  24.  
  25. [Int64] $myInt = 123456789 
  26. $myInt.ToString( "N", $nfi
  27.  
  28. $nfi.NumberDecimalSeparator = " " 
  29. $myInt.ToString( "N", $nfi

No comments: