Write a program to format the string expressions in the
given statements.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Csharp
{
/// <summary>
/// Working string argument formats
/// </summary>
class
strings
{
public
static void Main(string[] args)
{
string
sa = "Hello";
Console.WriteLine(sa);
foreach (string s in args)
{
Console.WriteLine(s);
}
strings obj = new strings();
obj.formats();
obj.strignbuilder();
Console.ReadLine();
}
public
void formats()
{
Console.WriteLine("The value: {0}.", 500); // Print out number
Console.WriteLine("The value of 12 in currency format\t: {0:C}.",
500);
Console.WriteLine("The value of 12 in Fixed Decimal format:\t {0 :D4}", 12);
Console.WriteLine("The value of 12 in Fixed - float format:\t {0
:F4}", 12.3456789);
Console.WriteLine("The value of 12 in general and default format:\t {0
:G4}", 12.3456789);
Console.WriteLine("The value of 12 in hexadecimal format:\t{0
:x}", 180026);
Console.WriteLine("The value of 12 in separator format:\t{0 :N2}",
12345678.54321);
Console.WriteLine("The value of 12 in percentage format:\t{0
:P2}", 0.1221897);
}
No comments:
Post a Comment