String::Format("Currency format: {0:c2}", dbl); : String Format « Data Type « Visual C++ .NET






String::Format("Currency format: {0:c2}", dbl);

 
#include "stdafx.h"

using namespace System;

int main()
{
   String^ str;
   int i = -73000;
   double dbl = 1005.01;

   // Formats for floating-point types:

   str = String::Format("Currency format: {0:c2}", dbl);
   Console::WriteLine(str);

}

   
  








Related examples in the same category

1.{ 0, -30 } 30 characters in width, left-justified
2.{ 1, 10 } 10 characters in width, right-justified
3.{ 2, 10:c2 } 10 characters in width, currency with 2 decimal places
4.String::Format("Scientific format: {0:e6}", dbl);
5.String::Format("Fixed-point format: {0:f6}", dbl);
6.String::Format("General format: {0:g6}", dbl);
7.String::Format("Number format: {0:n6}", dbl);
8.String::Format("Percent format: {0:p6}", dbl);
9.String::Format("Round-trip format: {0:r6}", dbl);
10.String::Format("Decimal format: {0:d6}", i);
11.String::Format("General format: {0:g6}", i);
12.String::Format("Number format: {0:n0}", i);
13.String::Format("Hexadecimal format: {0:x8}", i);