c# Round-trip 格式化

class DemoClass
{
    static void Main(string[] args)
    {

     const double number = 1.618033988749895;
        double result;
        string text;

        text = string.Format("{0}",number);
        result = double.Parse(text);
        Console.WriteLine(" {0}: result != number", result != number);

        text = string.Format("{0:R}", number);
        result = double.Parse(text);
        Console.WriteLine("{0}: result == number", result == number);

 

        Console.ReadKey();
    }
}

 

摘自《c#本质论》27页

 

posted @ 2012-03-05 15:10  辰楚风^_^  阅读(512)  评论(0编辑  收藏  举报