C# में डबल स्ट्रिंग फॉर्मेट के लिए स्टेटिक मेथड String.Format का उपयोग करें।
तीन दशमलव स्थानों के लिए:
String.Format("{0:0.000}", 987.383); String.Format("{0:0.000}", 987.38); String.Format("{0:0.000}", 987.7899);हजारों के सेपरेटर के लिए:
String.Format("{0:0,0.0}", 54567.46); String.Format("{0:0,0}", 54567.46);स्ट्रिंग फ़ॉर्मेट करने के लिए:
उदाहरण
using System; class Demo { public static void Main(String[] args) { Console.WriteLine("Three decimal places..."); Console.WriteLine( String.Format("{0:0.000}", 987.383)); Console.WriteLine( String.Format("{0:0.000}", 987.38)); Console.WriteLine(String.Format("{0:0.000}", 987.7899)); Console.WriteLine("Thousands Separator..."); Console.WriteLine(String.Format("{0:0,0.0}", 54567.46)); Console.WriteLine(String.Format("{0:0,0}", 54567.46)); } }