当前位置: 首页>>代码示例>>C#>>正文


C# StringBuilder.AppendLineFormat方法代码示例

本文整理汇总了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());
 }
开发者ID:rgshare,项目名称:Craig-s-Utility-Library,代码行数:10,代码来源:StringExtensions.cs

示例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());
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:16,代码来源:ArchivingTests.cs

示例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();
        }
开发者ID:hbre,项目名称:GitVersion,代码行数:18,代码来源:JsonOutputFormatter.cs

示例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();
        }
开发者ID:pierrebakker,项目名称:GitVersion,代码行数:18,代码来源:JsonOutputFormatter.cs

示例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();
 }
开发者ID:jerrymds,项目名称:Concord,代码行数:16,代码来源:SQLProfiler.cs


注:本文中的System.Text.StringBuilder.AppendLineFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。