Csharp/C Sharp by API/System/Double — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:31, 26 мая 2010

Double.Parse

 
using System;
public class NumericParsing
{
    public static void Main()
    {
        int value = Int32.Parse("99953");
        double dval = Double.Parse("1.3433E+35");
        Console.WriteLine("{0}", value);
        Console.WriteLine("{0}", dval);
    }
}


Double.ToString(CultureInfo ci)

  
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Globalization;
public class MainClass
{
    public static void Main()
    {
       string[] cultures = new string[] { "en-US", "en-GB", "es-MX", "de-DE", "ja-JP" };
        using (TextWriter sw = Console.Out)
        {
            foreach (string c in cultures)
            {
                CultureInfo ci = new CultureInfo(c);
                double number = -100299.55;
                sw.WriteLine("    Number Format: {0}", number.ToString(ci));
            }
        }
    }
}


Double.ToString(String format, CultureInfo info)

  
using System;
using System.Globalization;
using System.Windows.Forms;
public class MainClass
{
    static void Main() {
        CultureInfo germany  = new CultureInfo( "de-DE" );
        double money = 123.45;
        string localMoney = money.ToString( "C", germany );
        Console.WriteLine( localMoney );
    }
}