• <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 閱讀(186) 評論(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'.
            99精品国产在热久久无毒不卡 | 一本久久知道综合久久| 精品无码人妻久久久久久| 久久国产精品77777| 91精品免费久久久久久久久| 久久久久99精品成人片牛牛影视| 久久精品一区二区三区中文字幕| 久久一区二区免费播放| 久久亚洲国产精品成人AV秋霞| 国产精品美女久久久久| 国产真实乱对白精彩久久| 久久亚洲精品无码aⅴ大香| 热99re久久国超精品首页| 思思久久精品在热线热| 麻豆精品久久精品色综合| 国产69精品久久久久观看软件| 俺来也俺去啦久久综合网| 少妇久久久久久被弄到高潮| 国产日产久久高清欧美一区| 国产69精品久久久久APP下载| 日韩一区二区久久久久久 | 国产午夜福利精品久久| 国产精品乱码久久久久久软件 | 久久久久国产一区二区三区| 狠狠88综合久久久久综合网| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 国产婷婷成人久久Av免费高清 | 久久精品无码av| 精品999久久久久久中文字幕| 亚洲va久久久久| 久久久免费观成人影院| 国产成人精品久久| 国内精品久久久久影院免费| 少妇久久久久久被弄高潮| 精品人妻伦九区久久AAA片69| 思思久久99热免费精品6| 日韩精品无码久久一区二区三| 成人精品一区二区久久久| 女人香蕉久久**毛片精品| 国产亚洲婷婷香蕉久久精品| 成人免费网站久久久|