Advanced formatting rules for StringBuilder.AppendFormat

こ雲淡風輕ζ 提交于 2020-01-01 05:54:30

问题


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?


回答1:


  • Composite Formatting
  • Standard Numeric Format Strings
  • Custom Numeric Format Strings
  • Standard Date and Time Format Strings
  • Custom Date and Time Format Strings



回答2:


Are you looking for this ?




回答3:


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.



来源:https://stackoverflow.com/questions/3570370/advanced-formatting-rules-for-stringbuilder-appendformat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!