using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExamleStringFormat
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n Only two decimal Number");
Console.WriteLine("\n For two decimal we need to use pattern (0.00)");
Console.WriteLine("\n {0}", String.Format("{0:0.00}", 189.6667));
Console.WriteLine("\n {0}", String.Format("{0:0.00}", 183.894));
Console.WriteLine("\n {0}", String.Format("{0:0.00}", 196.0));
Console.WriteLine("\n Floating number of decimal Number");
Console.WriteLine("\n For Floating decimal we need to use pattern (0.##)");
Console.WriteLine("\n {0}", String.Format("{0:0.##}", 189.666745665845));
Console.WriteLine("\n {0}", String.Format("{0:0.##}", 183.8942654566));
Console.WriteLine("\n {0}", String.Format("{0:0.##}", 196.0));
Console.WriteLine("\n At least two digits before decimal point ");
Console.WriteLine("\n For decimal we need to use pattern (00.0)");
Console.WriteLine("\n {0}", String.Format("{0:00.0}", 189.4567));
Console.WriteLine("\n {0}", String.Format("{0:00.0}", 89.4567));
Console.WriteLine("\n {0}", String.Format("{0:00.0}", 9.4567));
Console.WriteLine("\n {0}", String.Format("{0:00.0}",-9.4567));
Console.WriteLine("\n Thousands separator");
Console.WriteLine("\n For Thousands separator we need to use pattern (0,0.0)");
Console.WriteLine("\n {0}", String.Format("{0:0,0.0}", 18129.4567));
Console.WriteLine("\n {0}", String.Format("{0:0,0}", 12589.4567));
Console.ReadLine();
}
}
}