易截截图软件、单文件、免安装、纯绿色、仅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# 代码的 html fragment 生成

测试语法高亮的 C# 代码的 html fragment 生成:
用csdn blog API 发布.
下面是:
public class HtmlWriter
{
   static Dictionary _colors;
   static int _colorNum;
   static StringBuilder _colorString;

[笔记]C#实现动态编译

今天看了我的老师钟声的书《Java程序员上班那点儿事》,其中有一段关于Java实现动态编译的代码使我很受启发,决定在.NET中尝试一下。
引入下列命名空间:
using System.CodeDom;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
C#代码:
     &n ......

C#Windows服务程序的快速开发


C#Windows服务程序的快速开发向你介绍了在很多应用中需要做windows服务来操作数据库等操作,希望对你了解C#Windows服务程序的开发有所帮助。
C#Windows服务程序的快速开发:在很多应用中需要做windows服务来操作数据库等操作,比如
(1)一些非常慢的数据库操作,不想一次性去做,想慢慢的通过服务定时去做,比如定时为 ......

C#利用winapi定位控件位置算法

public struct RECT
{
      public int left;
      public int Top;
      public int Right;
      public int Bottom;
}
public static bool CenterMouseOn(int hwnd)
{
     ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号