using System;
namespace TestString
{
/// <summary>
/// Stringのテストです。
/// </summary>
class TestString
{
static void Main(string[] args)
{
// String Format
Console.WriteLine("{0} = {0}, {1} != {2}", 1, 2, 3);
Console.WriteLine("\nCurrency format");
Console.WriteLine("c/C\t123 = {0:c}", -123);
Console.WriteLine("\nDecimal format");
Console.WriteLine("d/D\t123 = {0:d}", -123);
Console.WriteLine("d6/D6\t123 = {0:d6}", -123);
Console.WriteLine("\nScientific (exponential) format");
Console.WriteLine("e\t123.456 = {0:e}", -123.456);
Console.WriteLine("E\t123.456 = {0:E}", -123.456);
Console.WriteLine("E3\t123.456 = {0:E3}", -123.456);
Console.WriteLine("\nFixed-point format");
Console.WriteLine("f/F\t123.456 = {0:f}", -123.456);
Console.WriteLine("f5/F5\t123.456 = {0:f5}", -123.456);
Console.WriteLine("\nGeneral format");
Console.WriteLine("g/G\tHello World = {0:g}", "Hello World");
Console.WriteLine("g/G\t123.456 = {0:g}", -123.456);
Console.WriteLine("g2/G2\tHello World = {0:g2}", "Hello World");
Console.WriteLine("g2/G2\t123.456 = {0:g2}", -123.456);
Console.WriteLine("g\t123.456 = {0:g}", -123.456e-10);
Console.WriteLine("G\t123.456 = {0:G}", -123.456e-10);
Console.WriteLine("\nNumber format");
Console.WriteLine("n/N\t123456.789 = {0:n}", 123456.789);
Console.WriteLine("n5/N5\t123456.789 = {0:n5}", 123456.789123);
Console.WriteLine("\nPercent format");
Console.WriteLine("p/P\t123.456 = {0:p}", 123.456);
Console.WriteLine("p5/P5\t123.456 = {0:p5}", 123.456);
Console.WriteLine("\nHexadecimal format");
Console.WriteLine("x\t255 = {0:x}", 255);
Console.WriteLine("X\t255 = {0:X}", 255);
Console.WriteLine("X16\t255 = {0:X16}", 255);
Console.WriteLine("\nplaceholder");
Console.WriteLine("0###.##\t{0} = {0:0###.##}", Math.PI);
Console.WriteLine("0##.###\t{0} = {0:0##.###}", Math.PI);
Console.WriteLine("000.##\t{0} = {0:000.##}", Math.PI);
Console.WriteLine("%000.##\t{0} = {0:%000.##}", Math.PI);
Console.WriteLine("000.##E-00\t{0} = {0:000.##E-00}", Math.PI);
Console.WriteLine("000.##E+00\t{0} = {0:000.##E+000}", Math.PI);
Console.WriteLine("000.##e-00\t{0} = {0:000.##e-00}", Math.PI);
Console.WriteLine("000.##e+00\t{0} = {0:000.##e+0000}", Math.PI);
Console.WriteLine("\ncurly brackets and literal string ");
Console.WriteLine("0###.##\t{0} = {{{0:0###.##}}'literal string'}", Math.PI);
Console.WriteLine("\nSection separator");
Console.WriteLine( "{0:Positive Number = #.##;Negative Number = -#.##;Zero Value = #}", Math.PI);
Console.WriteLine( "{0:Positive Number = #;Negative Number = -#;Zero Value = #}", -Math.PI);
Console.WriteLine( "{0:Positive Number = #;Negative Number = -#;Zero Value = #}", 0);
}
}
}
|