當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。