Linda aqui te mando algunos ejemplos
El siguiente ejemplo muestra la manera en que se utilizan los especificadores de formato numérico estándar con el fin de dar formato a los tipos base numéricos.
[Visual Basic]
Imports System
Imports System.Globalization
Imports System.Threading
Module Module1
Sub Main()
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-us")
Dim MyDouble As Double = 123456789
Console.WriteLine("The examples in en-US culture:")
Console.WriteLine(MyDouble.ToString("C"))
Console.WriteLine(MyDouble.ToString("E"))
Console.WriteLine(MyDouble.ToString("P"))
Console.WriteLine(MyDouble.ToString("N"))
Console.WriteLine(MyDouble.ToString("F"))
Thread.CurrentThread.CurrentCulture = New CultureInfo("de-DE")
Console.WriteLine("The examples in de-DE culture:")
Console.WriteLine(MyDouble.ToString("C"))
Console.WriteLine(MyDouble.ToString("E"))
Console.WriteLine(MyDouble.ToString("P"))
Console.WriteLine(MyDouble.ToString("N"))
Console.WriteLine(MyDouble.ToString("F"))
End Sub
End Module
[C#]
using System;
using System.Threading;
using System.Globalization;
class Class1
{
static void Main()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
double MyDouble = 123456789;
Console.WriteLine("The examples in en-US culture.\n");
Console.WriteLine(MyDouble.ToString("C"));
Console.WriteLine(MyDouble.ToString("E"));
Console.WriteLine(MyDouble.ToString("P"));
Console.WriteLine(MyDouble.ToString("N"));
Console.WriteLine(MyDouble.ToString("F"));
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
Console.WriteLine("The examples in de-DE culture.\n");
Console.WriteLine(MyDouble.ToString("C"));
Console.WriteLine(MyDouble.ToString("E"));
Console.WriteLine(MyDouble.ToString("P"));
Console.WriteLine(MyDouble.ToString("N"));
Console.WriteLine(MyDouble.ToString("F"));
}
}
El ejemplo de código anterior muestra en la consola lo siguiente.
The examples in en-US culture:
$123,456,789.00
1.234568E+008
12,345,678,900.00%
123,456,789.00
123456789.00
The examples in de-DE culture:
123.456.789,00 DM
1,234568E+008
12,345,678,900.00%
123.456.789,00
123456789,00