{ 0, -30 } 30 characters in width, left-justified : String Format « Data Type « Visual C++ .NET

Home
Visual C++ .NET
1.2D
2.Class
3.Collections
4.Data Type
5.Database ADO.net
6.Delegate
7.Development
8.File Directory
9.Function
10.Generics
11.GUI Form
12.Language Basics
13.Network
14.Reflection
15.Security
16.Statement
17.Structure
18.Thread
19.XML
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Visual C++ .NET » Data Type » String Format 
{ 0, -30 } 30 characters in width, left-justified
 
#include "stdafx.h"

using namespace System;

int main()
{

   String^ format = "{0,-30}{1,10}{2,10:c2}";
   String^ header = String::Format(format, "Item""Quantity""Price");
   String^ str1 = str1->Format(format, "M"100.99);
   String^ str2 = str2->Format(format, "G"112.50);
   String^ str3 = str3->Format(format, "I"14.99);

   Console::WriteLine(header);
   Console::WriteLine(str1 + "\n" + str2 + "\n" + str3);
}

   
  
Related examples in the same category
1.{ 1, 10 } 10 characters in width, right-justified
2.{ 2, 10:c2 } 10 characters in width, currency with 2 decimal places
3.String::Format("Currency format: {0:c2}", dbl);
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);
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.