StringBuilder.AppendFormat 的高级格式化规则
我在此网站上看到了一个说明AppendFormat
用法的StringBuilder代码示例:
using System;
using System.Text;
class Program
{
static int[] _v = new int[]
{
1,
4,
6
};
static void Main()
{
StringBuilder b = new StringBuilder();
foreach (int v in _v)
{
b.AppendFormat("int: {0:0.0}{1}", v,
Environment.NewLine);
}
Console.WriteLine(b.ToString());
}
}
=== 程序输出 === 整数:1.0 整数:4.0 积分:6.0
在哪里可以找到有关字符串格式化的高级规则的文档?
I've seen on this site a StringBuilder code sample illustrating AppendFormat
usage:
using System;
using System.Text;
class Program
{
static int[] _v = new int[]
{
1,
4,
6
};
static void Main()
{
StringBuilder b = new StringBuilder();
foreach (int v in _v)
{
b.AppendFormat("int: {0:0.0}{1}", v,
Environment.NewLine);
}
Console.WriteLine(b.ToString());
}
}
=== Output of the program === int: 1.0 int: 4.0 int: 6.0
Where can I find documentation on those advanced rules for string formatting?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在寻找这个?
Are you looking for this ?
您可以首先查看 MSDN 上的复合格式文章。从那里您将找到 数字 和 < a href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx" rel="nofollow noreferrer">日期,以及指向 数字 和 日期。
You can start by checking the Composite Formatting article at MSDN. From there you will find links to standard format strings for numbers and dates, as well as links to the custom format strings for both numbers and dates.