• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            IFormattable

            Posted on 2009-07-06 15:57 Hero 閱讀(184) 評論(0)  編輯 收藏 引用 所屬分類: C#積累
             1 using System;
             2 
             3 class Point : IFormattable
             4 {
             5     public int x, y;
             6 
             7     public Point(int x, int y)
             8     {
             9         this.x = x;
            10         this.y = y;
            11     }
            12 
            13     public override String ToString() { return ToString(nullnull); }
            14 
            15     public String ToString(String format, IFormatProvider fp)
            16     {
            17         // If no format is passed, display like this: (x, y).
            18         if (format == nullreturn String.Format("({0}, {1})", x, y);
            19 
            20         // For "x" formatting, return just the x value as a string
            21         if (format == "x"return x.ToString();
            22 
            23         // For "y" formatting, return just the y value as a string
            24         if (format == "y"return y.ToString();
            25 
            26         // For any unrecognized format, throw an exception.
            27         throw new FormatException(String.Format("Invalid format string: '{0}'.", format));
            28     }
            29 }
            30 
            31 
            32 public sealed class App
            33 {
            34     static void Main()
            35     {
            36         // Create the object.
            37         Point p = new Point(598);
            38 
            39         // Test ToString with no formatting.
            40         Console.WriteLine("This is my point: " + p.ToString());
            41 
            42         // Use custom formatting style "x"
            43         Console.WriteLine("The point's x value is {0:x}", p);
            44 
            45         // Use custom formatting style "y"
            46         Console.WriteLine("The point's y value is {0:y}", p);
            47 
            48         try 
            49         {
            50             // Use an invalid format; FormatException should be thrown here.
            51             Console.WriteLine("Invalid way to format a point: {0:XYZ}", p);
            52         }
            53         catch (FormatException e)
            54         {
            55             Console.WriteLine("The last line could not be displayed: {0}", e.Message);
            56         }
            57     }
            58 }
            59 
            60 // This code produces the following output.
            61 // 
            62 //  This is my point: (5, 98)
            63 //  The point's x value is 5
            64 //  The point's y value is 98
            65 //  The last line could not be displayed: Invalid format string: 'XYZ'.
            久久久无码精品亚洲日韩京东传媒| 伊人热热久久原色播放www| 男女久久久国产一区二区三区| 中文字幕日本人妻久久久免费| 久久国产精品成人影院| 久久精品国产亚洲欧美| 一级做a爰片久久毛片看看| 色妞色综合久久夜夜| 国内精品伊人久久久久网站| 久久久久国产精品人妻| 久久国产精品国产自线拍免费| 久久男人中文字幕资源站| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 成人资源影音先锋久久资源网| 91精品观看91久久久久久| 久久AV高潮AV无码AV| 韩国三级中文字幕hd久久精品| 亚洲精品无码成人片久久| 久久涩综合| 国产成人综合久久久久久| 国产亚洲综合久久系列| 麻豆av久久av盛宴av| 久久国产视频99电影| 999久久久免费精品国产| 久久精品成人免费国产片小草| 亚洲精品乱码久久久久久按摩 | 波多野结衣久久精品| 精品久久久久久无码人妻热| 久久A级毛片免费观看| 99精品久久精品一区二区| 久久99热这里只频精品6| 久久无码AV中文出轨人妻 | 精品熟女少妇AV免费久久| 日本加勒比久久精品| 久久久久久久久久久免费精品| 久久香蕉综合色一综合色88| 久久久国产精品亚洲一区| 久久久婷婷五月亚洲97号色 | 久久e热在这里只有国产中文精品99| 国产亚洲综合久久系列| 国产精品毛片久久久久久久 |