• <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>

            我希望你是我獨(dú)家記憶

            一段永遠(yuǎn)封存的記憶,隨風(fēng)而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁(yè) :: 新隨筆 ::  :: 聚合  :: 管理

            IFormattable

            Posted on 2009-07-06 15:57 Hero 閱讀(181) 評(píng)論(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热这里只有精品66| 久久人人爽人人爽人人爽| 久久综合色区| 中文字幕久久精品| 亚洲国产精品无码成人片久久| 99久久香蕉国产线看观香| 久久人人爽人人爽人人片av麻烦| yy6080久久| 97久久超碰国产精品2021| 久久久久久久尹人综合网亚洲 | 亚洲国产视频久久| 狠狠色丁香久久婷婷综合蜜芽五月| 香蕉99久久国产综合精品宅男自 | 久久香蕉国产线看观看99| 色综合合久久天天综合绕视看| 久久99精品久久久久久不卡| 色综合合久久天天给综看| 国内精品伊人久久久久777| 久久精品九九亚洲精品| 丁香五月综合久久激情| 国产精品久久久香蕉| 国产Av激情久久无码天堂| 99久久精品国产一区二区| 四虎影视久久久免费| 久久夜色精品国产噜噜亚洲AV| 国产91色综合久久免费分享| 免费精品久久久久久中文字幕| 香蕉久久av一区二区三区| 久久91这里精品国产2020| 久久久久久曰本AV免费免费| 美女写真久久影院| 久久久久久精品无码人妻| 91精品国产高清久久久久久91| 久久妇女高潮几次MBA| 久久综合综合久久狠狠狠97色88| 午夜精品久久久久9999高清| 久久九九亚洲精品| 久久棈精品久久久久久噜噜| 国产精品中文久久久久久久| 国产毛片久久久久久国产毛片 |