Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c# String[1].Format¸ñʽ˵Ã÷

C#¸ñʽ»¯ÊýÖµ½á¹û±í
×Ö·û
˵Ã÷
ʾÀý
Êä³ö
C
»õ±Ò
string.Format("{0:C3}", 2)
¡ç2.000
D
Ê®½øÖÆ
string.Format("{0:D3}", 2)
002
E
¿Æѧ¼ÆÊý·¨
1.20E+001
1.20E+001
G
³£¹æ
string.Format("{0:G}", 2)
2
N
Ó÷ֺŸô¿ªµÄÊý×Ö
string.Format("{0:N}", 250000)
250,000.00
X
Ê®Áù½øÖÆ
string.Format("{0:X000}", 12)
C
 
 
string.Format("{0:000.000}", 12.2)
012.200
Strings
There really isn't any formatting within a strong, beyond it's alignment. Alignment works for any argument being printed in a String.Format call.
 
Sample
Generates
String.Format("->{1,10}<-", "Hello");
-> Hello<-
String.Format("->{1,-10}<-", "Hello");
->Hello <-
Numbers
Basic number formatting specifiers:
 
Specifier
Type
Format
Output
(Passed
Double 1.42)
Output
(Passed
Int -12400)
c
Currency
{0:c}
¡ç1.42
-¡ç12,400
d
Decimal (Whole number)
{0:d}
System.
FormatException
-12400
e
Scientific
{0:e}
1.420000e+000
-1.240000e+004
f
Fixed point
{0:f}
1.42
-12400.00
g
General
{0:g}
1.42
-12400
n
Number with commas for thousands
{0:n}
1.42
-12,400
r
Round trippable
{0:r}
1.42
System.
FormatException
x
Hexadecimal
{0:x4}
System.
FormatException
cf90
Custom number formatting:
 
Specifier
Type
Example
Output (Passed Double 1500.42)
Note
0
Zero placeholder
{0:00.0000}
1500.4200
Pads with zeroes.
#
Digit placeholder
{0:(#).##}
(1500).42
 
.
Decimal point
{0:0.0}
1500.4
 
,
Thousand separator
{0:0,0}
1,500
Must be between two zeroes.
,.
Number scaling
{0:0,.}
2
Comma adjacent to Period scales by 1000.
%
Percent
{0:0%}
150042%
Multiplies by 100, adds % sign.
e
Exponent placeholder
{0:00e+0}
15e+2
Many exponent formats available.
;
Group separator
see below
 
 
The group separator is especially useful for formatting currency values which require that negative values be enclosed in parentheses. This currency formatting examp


Ïà¹ØÎĵµ£º

C#´¦ÀíXML

ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
  <book genre="fantasy" ISBN="2-3631-4">
    <title>Oberon's Legacy</title>
    <author>Corets, Eva</author>
  &nb ......

C# ʼþÓëίÍÐȤ̸

ʼþÓëίÍÐËƺõºÜÄÑÒÔÀí½â£¬ÕâÊÇÒòΪËüÃǵÄʹÓ÷½Ê½Óë³£ÓõıàÂëÓкܴóµÄ²î±ð£¬ÀýÈçͨ³£±àдµÄ¶¼ÊÇͬ²½´úÂ룬µ÷ÓÃÒ»¸öÀàÐ͵ķ½·¨£¬»á¼´¿Ì³öÏÖ·½·¨Ö´
ÐеĽá¹û£¬ÕâÊÇ·ûºÏÂß¼­µÄ¡£µ«ÔÚijЩÇé¿öÖУ¬Í¬²½´úÂëδ±ØÂú×ãÐèÇó£¬Äù«¹²Æû³µÀ´´ò¸ö±È·½£¬Èç¹û½»Í¨¹ÜÖÆÖÐÐÄÏ£ÍûÿһÁ¾¹«³µµ½´ïÒ»¸öÕ¾µãʱ¶¼·¢Ë͸ø×Ô¼ºÒ»
¸öÐźÅÒÔ±ã×Ô¼º ......

C#ʵÏÖ³ÌÐòµÄ°æ±¾Éý¼¶¸üÐÂ

   ÎÒÃÇ×öÁ˳ÌÐò£¬²»Ãâ»áÓа汾Éý¼¶£¬Õâ¾ÍÐèÒª³ÌÐòÓÐ×Ô¶¯°æ±¾Éý¼¶µÄ¹¦ÄÜ¡£
ÄÇô¿´¿´ÎÒÊÇÈçºÎʵÏÖ³ÌÐò×Ô¶¯¸üеġ£
Ö±½ÓÉÏ´úÂ룺
 using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using System.Net;
using System.Xml;
namespace ......

C#ÀûÓÃwinapi²¶×½Êó±ê²Ù×÷¿Ø¼þµÄ¾ä±ú

public struct POINTAPI
{
   public int x;
   public int y;
}
public static void GetWindowfromPoint(ref int hwnd,ref StringBuilder winText,ref StringBuilder clsName,ref StringBuilder pText)
{
  int parentHandle=0;
  int maxLen=128;
  POINTAPI pnt = new ......

C# ref¹Ø¼ü×ÖµÄÀí½â

ÎÞÒâÖп´µ½ref¹Ø¼ü×Ö£¬Ö»¼ÇµÃÒ»¿ªÊ¼Ñ§Ï°C#µÄʱºò£¬ÓкܶණÎ÷¶¼Ìø¹ýÈ¥ÁË¡£ ½ñÌì¸Õ¿´¼ûÕâ¸ö¹Ø¼ü×ÖµÄʱºò£¬»¹Õæ²»ÖªµÀËüÓÐʲôÌرðµÄµØ·½¡£googleÁËһϣ¬ÕÒµ½Ò»Æª½âÊÍµÄ±È½Ï ºÃµÄÎÄÕ¡£ÈçÏ£º C# ÖеıäÁ¿ C# ÖеÄÊý¾ÝÓÐÁ½ÖÖÀàÐÍ£ºÒýÓÃÀàÐÍ£¨reference types£©ºÍÖµÀàÐÍ£¨value types£©¡£ ¼òµ¥ÀàÐÍ£¨°üÀ¨int, long, doubleµÈ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ