Posts

String Format

The following example demonstrates the standard formatting specifiers for numbers, dates, and enumerations. // This code example demonstrates the Console.WriteLine() method. // Formatting for this example uses the "en-US" culture. using System; class Sample { enum Color {Yellow = 1 , Blue, Green}; static DateTime thisDate = DateTime.Now; public static void Main ( ) { Console.Clear(); // Format a negative integer or floating-point number in various ways. Console.WriteLine( "Standard Numeric Format Specifiers" ); Console.WriteLine( "(C) Currency: . . . . . . . . {0:C}\n" + "(D) Decimal:. . . . . . . . . {0:D}\n" + "(E) Scientific: . . . . . . . {1:E}\n" + "(F) Fixed point:. . . . . . . {1:F}\n" + "(G) General:. . . . . . . . . {0:G}\n" + " (default):. . . . . . . . {0} (default = 'G')\n" + "(N) Number: . . . . . . . . . {0:N}\n" + "(P) Percent:. . . . . . . . . {1
Recent posts