CCur


Definition: Returns an expression that has been converted to a Variantof subtype Currency.

 

Windows PowerShell uses the same data types as the .NET Framework; because the .NET Framework does not support the Currency data type that means Windows PowerShell doesn’t support this data type, either. However, while you cannot convert a variable to the Currency data type you can at least format the value so that it looks like a currency value when displayed onscreen. The following command assigns the value 13 to the variable $ a andformats the value so it displays as currency:

 

$a = "{0 :C}" -f 13

 

This command uses the .NET Framework currency formatting string “{0 :C}”to format the value as currency (note that the value to be formatted is included as part of the –fparameter).

When you run the command and then echo back the value of $ a youshould get the following:

 

$13.00