• <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 閱讀(181) 評論(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'.
            国产精品久久久久乳精品爆| 亚洲国产成人精品女人久久久| 97精品国产97久久久久久免费 | 99久久综合狠狠综合久久止| 久久99国内精品自在现线| 久久国产精品国产自线拍免费| 国产午夜精品久久久久九九电影 | 久久99国产乱子伦精品免费| 韩国三级中文字幕hd久久精品| 久久精品国产国产精品四凭| 亚洲狠狠婷婷综合久久久久| 精品一区二区久久久久久久网站| 日韩精品久久久久久久电影| 99久久精品国内| 久久精品国产亚洲av麻豆蜜芽| 久久国产精品成人免费 | 久久久一本精品99久久精品88| 久久人妻少妇嫩草AV无码专区| 久久久久久久综合综合狠狠| 国内精品久久久久影院优| 亚洲国产精品成人久久蜜臀| 久久精品国产福利国产秒| 丁香色欲久久久久久综合网| 精品无码久久久久久国产| 狠狠色婷婷久久一区二区三区 | 亚洲欧美精品一区久久中文字幕| 国产成人精品久久免费动漫| 一本一本久久aa综合精品| 色综合久久中文字幕综合网| 国产日韩久久久精品影院首页| 国内精品人妻无码久久久影院| 亚洲va久久久噜噜噜久久| 亚洲av成人无码久久精品| 亚洲中文字幕久久精品无码喷水| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 精品国产乱码久久久久软件 | 国产精品成人99久久久久91gav| 国内精品久久久久| 国产精品午夜久久| 久久久久久A亚洲欧洲AV冫| 色综合合久久天天给综看|