Composite format strings combines variable substitution with format strings.
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
string composite = "Credit={0:C}";
Console.WriteLine(string.Format(composite, 500)); // Credit=$500.00
}
}
The output:
Credit=$500.00
The Console
class overloads its Write
and WriteLine
methods to accept composite format strings.
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
Console.WriteLine("Credit={0:C}", 500); // Credit=$500.00
}
}
The output:
Credit=$500.00
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |