<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      String.Format格式化字符串一覽

      Zeichenketten und Datumswerte formatieren

      Oft kommt es vor, dass man Zeichenketten und Datumswerte in einem bestimmten Format ausgeben muss. Das Microsoft Framework stellt eine m?chte Methode zur Verfügung mit der man einfach und schnell Formatvorlagen auf Zeichenketten oder Datumswerte anwenden kann: String.Format().

      Im folgenden findet man die wichtigtens Formate:

      Format Aufruf Ergebnis
      Zahlen mit vordefiniertem Format formatieren (zahl = 1000000)
      c String.Format("{0:c}", zahl) 1.000.000.00 ?
      d String.Format("{0:d}", zahl) 1000000
      e String.Format("{0:e}", zahl) 1000000e+006
      f String.Format("{0:f}", zahl) 1000000,00
      g String.Format("{0:g}", zahl) 1000000
      n String.Format("{0:n}", zahl) 1.000.000.00
      x String.Format("{0:x}", zahl) f4240
      Zahlen mit eigenem Format formatieren (zahl = 1000000)
      0 String.Format("{0:00.0000}", zahl) 1000000,0000
      # String.Format("{0:(#).##}", zahl) (1000000)
      . String.Format("{0:0.0}", zahl) 1000000,0
      , String.Format("{0:0,0}", zahl) 1.000.000
      ,. String.Format("{0:0,.}", zahl) 1000
      % String.Format("{0:0%}", zahl) 100000000%
      e String.Format("{0:00e+0}", zahl) 10e+5
       
      Datum mit vordefiniertem Format formatieren
      u String.Format("{0:u}", DateTime.Now) 2003-12-03 14:43:36Z
      U String.Format("{0:U}", DateTime.Now) Mittwoch, 3. Dezember 2003 13:43:36
      r String.Format("{0:r}", DateTime.Now) Wed, 03 Dec 2003 14:43:36 GMT
      s String.Format("{0:s}", DateTime.Now) 2003-12-03T14:43:36
      Y String.Format("{0:Y}", DateTime.Now) Dezember 2003
      g String.Format("{0:g}", DateTime.Now) 03.12.2003 14:43
      G String.Format("{0:G}", DateTime.Now) 03.12.2003 14:43:36
      M String.Format("{0:M}", DateTime.Now) 03 Dezember
      d String.Format("{0:d}", DateTime.Now) 03.12.2003
      D String.Format("{0:D}", DateTime.Now) Mittwoch, 3. Dezember 2003
      t String.Format("{0:t}", DateTime.Now) 14:43
      T String.Format("{0:T}", DateTime.Now) 14:43:36
      f String.Format("{0:f}", DateTime.Now) Mittwoch, 3. Dezember 2003 14:43
      F String.Format("{0:F}", DateTime.Now) Mittwoch, 3. Dezember 2003 14:43:36
      Datum mit eigenem Format formatieren
      dd String.Format("{0:F}", DateTime.Now) 03
      ddd String.Format("{0:F}", DateTime.Now) Mi
      dddd String.Format("{0:F}", DateTime.Now) Mittwoch
      MM String.Format("{0:F}", DateTime.Now) 12
      MMM String.Format("{0:F}", DateTime.Now) Dez
      MMMM String.Format("{0:F}", DateTime.Now) Dezember
      yy String.Format("{0:F}", DateTime.Now) 03
      yyyy String.Format("{0:F}", DateTime.Now) 2003
      ss String.Format("{0:F}", DateTime.Now) 36
      mm String.Format("{0:F}", DateTime.Now) 43
      hh String.Format("{0:F}", DateTime.Now) 02
      HH String.Format("{0:F}", DateTime.Now) 14
      gg String.Format("{0:F}", DateTime.Now) n. Chr.
      tt String.Format("{0:F}", DateTime.Now)
      zz String.Format("{0:F}", DateTime.Now) +01
      zzz String.Format("{0:F}", DateTime.Now) +01:00

      第二部分:

      String.Format("{0}", "formatting string"};
      Tue, 14 Jul 2004 19:30:00 GMT
      One of the painful things about good old ASP was string formatting, VBScript simply didn't have anything useful. C# (and VB.Net) do, but MSDN doesn't provide a quick reference to the formatting options. So here's a quick reference.

      To compare string formatting in C# to those in C lets have an example,

      char szOutput[256];
      sprintf(szOutput, "At loop position %d.\n", i);


      sprintf takes an output buffer, a format string and any number of arguments to substitute into the format string.

      The C# equivalent for sprintf is String.Format, which takes a format string and the arguments. It returns a string, and because you're not passing in a buffer there's no chance of a buffer overflow.

      string outputString = String.Format("At loop position {0}.\n", i);


      So why doesn't have the format argument have parameters specifying what data type you're formatting? The CLR objects have metadata which informs the CLR what the objects are, and each object has a standard ToString() method which returns a string representation of that object. Much nicer than C where if you passed the wrong type of variable into sprintf everything could come crashing down.

      The ToString method can accept a string parameter which tells the object how to format itself. In the call to String.Format , the formatting string is passed after the position, for example, "{0:##}". The text inside the curly braces is {argumentIndex[,alignment][:formatString]}. If alignment is positive, the text is right-padding to fill the specified field length, if it's negative, it's left-padded.

      formatting strings
      There's not much formatting that can be applied to a string. Only the padding / alignment formatting options can be applied. These options are also available to every argument, regardless of type.

      example output
      String.Format("--{1,10}--", "test"); --      test--
      String.Format("--{1,-10}--", "test"); --test      --


      formatting numbers
      Number formatting is culture dependant. For example, formatting a currency string on my laptop will return a result like £9.99, formatting a currency on a machine set for the US region would return $9.99.

      specifier type format output
      (double 1.2345) output
      (int -12345)
      c currency {0:c} £1.23 -£12,345.00
      d decimal
      (whole number) {0:d} System.FormatException -12345
      e exponent / scientific {0:e} 1.234500e+000 -1.234500e+004
      f fixed point {0:f} 1.23 -12345.00
      g general {0:g} 1.2345 -12345
      n number {0:n} 1.23 -12,345.00
      r round trippable {0:r} 1.23 System.FormatException
      x hexadecimal {0:x4} System.FormatException ffffcfc7


      custom number formatting
      specifier type format output
      (double 1234.56)
      0 zero placeholder {0:00.000} 1234.560
      # digit placeholder {0:#.##} 1234.56
      . decimal point placeholder {0:0.0} 1234.6
      , thousand separator {0:0,0} 1,235
      % percentage {0:0%} 123456%


      In addition there is the group separator; this is useful for varying the format, depending on the value of the parameter passed. For example

      String.Format("{0:£#,##0.00;(£#,##0.00);Nothing}", value);


      This will output "£1,240.00" if passed 1243.56.  It will output the same format bracketed if the value is negative "(£1,240.00)", and will output the string "Nothing" if the number is zero.

      date formatting
      Date formats are very dependant on the culture information passed. The examples below are shown using the UK culture.

      specifier type output
      (June 8, 1970 12:30:59)
      d Short Date 08/06/1970
      D Long Date 08 June 1970
      t Short Time 12:30
      T Long Time 12:30:59
      f Full date and time 08 June 1970 12:30
      F Full date and time (long) 08 June 1970 12:30:59
      g Default date and time 08/06/1970 12:30
      G Default date and time (long) 08/06/1970 12:30:59
      M Day / Month 8 June
      r RFC1123 date string Mon, 08 Jun 1970 12:30:59 GMT
      s Sortable date/time 1970-06-08T12:30:59
      u Universal time, local timezone 1970-06-08 12:30:59Z
      Y Month / Year June 1970


      custom date formatting
      specifier type output
      (June 8, 1970 12:30:59)
      dd Day 08
      ddd Short Day Name Mon
      dddd Full Day Name Monday
      hh 2 digit hour 12
      HH 2 digit hour (24 hour) 12
      mm 2 digit minute 30
      MM Month 06
      MMM Short Month name Jun
      MMMM Month name June
      ss seconds 59
      tt AM/PM PM
      yy 2 digit year 70
      yyyy 4 digit year 1970
      : seperator, e.g. {0:hh:mm:ss} 12:30:59
      / seperator, e.g. {0:dd/mm/yyyy} 08/06/1970


      There are others, including time zone formatting and so on, but the ones above are the most commonly used.

      culture information
      string.format also provides a method which accepts a CultureInfo argument, as an IFormatProvider. This is important when trying to write portable and localisable code, as, for example, month names will change according to the local culture of the machine you are running on. Rather than simply call the standard String.Format you should consider always calling the overloaded culture method. If you don't need to specify a culture you can use the System.Globalization.CultureInfo.InvariantCulture. This will then default your formatting to English, as opposed to the culture of the current thread.

      posted @ 2007-02-01 18:03  chinaifne  閱讀(2799)  評論(1)    收藏  舉報
      主站蜘蛛池模板: 国产99青青成人A在线| 国产成人免费高清激情视频| 老司机午夜福利视频| 免费AV片在线观看网址| 天堂av资源在线免费| 精品国产成人三级在线观看| 国产中文一区卡二区不卡| 在线观看无码av五月花| 999精品色在线播放| 偷偷色噜狠狠狠狠的777米奇| 久久丁香五月天综合网| 国产喷水1区2区3区咪咪爱av| 自拍偷在线精品自拍偷免费| 成人年无码av片在线观看| 秋霞电影院午夜无码免费视频| 亚洲a人片在线观看网址| 亚洲熟妇自偷自拍另类| 精品视频国产狼友视频| 欧美日本精品一本二本三区| 精品国产一区二区三区国产区| 昂仁县| 91偷自国产一区二区三区| 92精品国产自产在线观看481页| 国产精品麻豆中文字幕| 亚洲国产无套无码av电影| 亚洲精中文字幕二区三区| 内射干少妇亚洲69xxx| 国产女人水真多18毛片18精品| 激情内射亚洲一区二区三区| 国产精品成人午夜久久| 亚洲av无码乱码在线观看野外| 国产三级a三级三级| 人妻丰满熟妇av无码处处不卡| 无码专区 人妻系列 在线| 亚洲国产午夜精品理论片妓女 | 麻豆精品一区二区综合av| 亚洲一区二区三区av激情| 国产一区二区日韩经典| 日韩熟妇中文色在线视频| 国产成人一区二区三区在线| 荡乳尤物h|