本文整理汇总了C#中System.Text.StringBuilder.AppendLineFormat方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendLineFormat方法的具体用法?C# StringBuilder.AppendLineFormat怎么用?C# StringBuilder.AppendLineFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.AppendLineFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendLineFormat
public void AppendLineFormat()
{
StringBuilder Builder = new StringBuilder();
Builder.AppendLineFormat("This is test {0}", 1);
Assert.Equal("This is test 1" + System.Environment.NewLine, Builder.ToString());
Builder.Clear();
Builder.AppendLineFormat("Test {0}", 2)
.AppendLineFormat("And {0}", 3);
Assert.Equal("Test 2" + System.Environment.NewLine + "And 3" + System.Environment.NewLine, Builder.ToString());
}
示例2: StringBuilder_AppendLineFormat
public void StringBuilder_AppendLineFormat()
{
var A = "A";
var B = "B";
var C = "C";
var format = "{0}{1}{2}";
var delimiter = ";;";
var expected = "ABC;;CBA;;BCA";
var sb = new StringBuilder();
sb.AppendLineFormat(format, new object[] { A, B, C }, delimiter);
sb.AppendLineFormat(format, new object[] { C, B, A }, delimiter);
sb.AppendLineFormat(format, new object[] { B, C, A }, delimiter);
Assert.AreEqual(expected, sb.ToString());
}
示例3: ToJson
public static string ToJson(Dictionary<string, string> variables)
{
var builder = new StringBuilder();
builder.AppendLine("{");
var last = variables.Last().Key;
foreach (var variable in variables)
{
var isLast = (variable.Key == last);
int value;
if (int.TryParse(variable.Value, out value))
builder.AppendLineFormat(" \"{0}\":{1}{2}", variable.Key, value, isLast ? string.Empty : ",");
else
builder.AppendLineFormat(" \"{0}\":\"{1}\"{2}", variable.Key, variable.Value, isLast ? string.Empty : ",");
}
builder.Append("}");
return builder.ToString();
}
示例4: ToJson
public static string ToJson(VersionVariables variables)
{
var builder = new StringBuilder();
builder.AppendLine("{");
var last = variables.Last().Key;
foreach (var variable in variables)
{
var isLast = (variable.Key == last);
int value;
if (int.TryParse(variable.Value, out value) && variable.Value[0] != '0') // preserve leading zeros for padding
builder.AppendLineFormat(" \"{0}\":{1}{2}", variable.Key, value, isLast ? string.Empty : ",");
else
builder.AppendLineFormat(" \"{0}\":\"{1}\"{2}", variable.Key, variable.Value, isLast ? string.Empty : ",");
}
builder.Append("}");
return builder.ToString();
}
示例5: ToHTML
/// <summary>
/// Outputs the profiler information as an HTML table
/// </summary>
/// <returns>Table containing profiler information</returns>
public override string ToHTML()
{
CompileData();
StringBuilder Builder = new StringBuilder();
Builder.AppendFormat(CultureInfo.InvariantCulture, "<tr><td>{0}</td><td>", CalledFrom);
Builder.AppendFormat(CultureInfo.InvariantCulture, "{0}</td><td>{1}ms</td><td>{2}ms</td><td>{3}ms</td><td>{4}ms</td><td>{5}</td></tr>", Query, Times.Sum(), Times.Max(), Times.Min(), string.Format(CultureInfo.InvariantCulture, "{0:0.##}", Times.Average()), Times.Count);
foreach (Profiler Child in Children)
{
Builder.AppendLineFormat(Child.ToHTML());
}
return Builder.ToString();
}