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


C# StringBuilder.AppendLines方法代码示例

本文整理汇总了C#中StringBuilder.AppendLines方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendLines方法的具体用法?C# StringBuilder.AppendLines怎么用?C# StringBuilder.AppendLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuilder的用法示例。


在下文中一共展示了StringBuilder.AppendLines方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAppendLinesMultiple

        public void TestAppendLinesMultiple()
        {
            var sB = new StringBuilder();

            sB.AppendLines("a", "b", "c");
            sB.ToString().ShouldEqual("a" + Environment.NewLine + "b" + Environment.NewLine + "c" + Environment.NewLine);
        }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:7,代码来源:StringBuilderExtensionsTests.cs

示例2: AppendLines_ES

        public void AppendLines_ES()
        {
            var b = new StringBuilder();
            var nl = Environment.NewLine;

            var items = new List<string> { "", "", "", "" };
            var buf = b.AppendLines(items).ToString();

            Expect(buf.ToString(), Is.EqualTo(nl+nl+nl+nl));
        }
开发者ID:lcaballero,项目名称:LucidEdge,代码行数:10,代码来源:Test_Append_Lines.cs

示例3: ToLogString

        /// <summary>
        /// Extension to provide a loggable string representing all information about an exception and its inner exceptions.
        /// </summary>
        /// <param name="ex">The exception to log</param>
        /// <param name="additionalMessage"> An optional additional message to log</param>
        /// <returns> a loggable string representing all information about an exception and its inner exceptions.</returns>
        public static string ToLogString(this Exception ex, string additionalMessage = "")
        {
            var msg = new StringBuilder();

            if (!string.IsNullOrEmpty(additionalMessage))
                msg.AppendLine(additionalMessage);

            if (ex == null)
                return msg.ToString();

            var orgEx = ex;
            msg.AppendLine("Exception:");
            while (orgEx != null)
            {
                msg.AppendLine(orgEx.Message);
                orgEx = orgEx.InnerException;
            }

            foreach (var i in ex.Data)
            {
                msg.Append("Data :");
                msg.AppendLine(i.ToString());
            }

            if (ex.StackTrace != null)
                msg.AppendLines("StackTrace:", ex.StackTrace);

            if (ex.Source != null)
                msg.AppendLines("Source:", ex.Source);

            if (ex.TargetSite != null)
                msg.AppendLines("TargetSite:", ex.TargetSite.ToString());

            msg.AppendLine("BaseException:");
            msg.Append(ex.GetBaseException());
            return msg.ToString();
        }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:43,代码来源:ExceptionExtensions.cs

示例4: GenerateCheckingCode

		private static string GenerateCheckingCode(int numberOfMasks, int numberOfHashesPerKey, uint[] Bitmask, uint[] Pattern, int numberOfPatterns)
		{
			StringBuilder builder = new StringBuilder();

			// Makes the checking code do a simple 3-word check for a single pattern
			// instead of using the hashtable (about 8% faster)
            if(numberOfMasks == 1 && numberOfHashesPerKey == 1 && numberOfPatterns == 1)
            {
                builder.AppendLine("if(((H[0] & {0}u) == {1}u) && ((H[1] & {2}u) == {3}u) && ((H[2] & {4}u) == {5}u))",
                    Bitmask[0],Pattern[0], Bitmask[1],Pattern[1], Bitmask[2],Pattern[2] );
                builder.AppendLine("        Results[get_local_id(0) % ResultsArraySize] = exp;");
            }
            else
            {
                for (int m = 0; m < numberOfMasks; m++)
                {
                    builder.AppendLine("BEGIN_MASK({0})", m);
                    builder.AppendLines(Util.Range(numberOfHashesPerKey)
                        .Select(i => string.Format("    CHECK_HASH({0})", i)));
                }
            }
			return builder.ToString();
		}
开发者ID:challal,项目名称:scallion,代码行数:23,代码来源:KernelGenerator.cs

示例5: AddGroups

        /// <summary>
        /// Adds lines of text in groups of a specified size to the StringBuilder.
        /// </summary>
        /// <param name="groupSize">Number of strings in each group</param>
        /// <param name="groupName">What to name each group.</param>
        /// <param name="lines">Lines to add</param>
        private static void AddGroups(StringBuilder sb, int groupSize, string groupName, IList<string> lines)
        {
            if (lines.Count == 0)
            {
                return;
            }
            else if (lines.Count <= groupSize)
            {
                if (groupName != string.Empty)
                    sb.Append(groupName + "\n");
                sb.AppendLines(lines);
            }
            else
            {
                int i = 0;
                int j = 1;
                for (i = 0; (i + 1) * groupSize < lines.Count; i++)
                {
                    if (groupName != string.Empty)
                        sb.Append(string.Format("{0}\\(part {1})\n", groupName, j++));
                    sb.AppendLines(lines.Sub(i * groupSize, (i + 1) * groupSize - 1));
                }

                if (groupName != string.Empty)
                    sb.Append(string.Format("{0}\\(part {1})\n", groupName, j++));
                sb.AppendLines(lines.Sub(i * groupSize, lines.Count - 1));
            }
        }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:34,代码来源:Codes.cs

示例6: ENV

        public Response ENV(dynamic parameters)
        {
            var sb = new StringBuilder("<html><body><pre>");

            RequestHeaders hdrs = Request.Headers;

            sb.AppendLine("Accept:");
            sb.AppendLines(hdrs.Accept);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("AcceptCharset:");
            sb.AppendLines(hdrs.AcceptCharset);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("AcceptEncoding:");
            sb.AppendLines(hdrs.AcceptEncoding);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("AcceptLanguage:");
            sb.AppendLines(hdrs.AcceptLanguage);
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("Authorization: ");
            sb.AppendLine(hdrs.Authorization);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("CacheControl:");
            sb.AppendLines(hdrs.CacheControl);
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("ContentType: ");
            sb.AppendLine(hdrs.ContentType);
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("Date: ");
            sb.AppendLine(hdrs.Date.ToString());
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("Host: ");
            sb.AppendLine(hdrs.Host);
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("MaxForwards: ");
            sb.AppendLine(hdrs.MaxForwards.ToString());
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("Referrer: ");
            sb.AppendLine(hdrs.Referrer);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("UserAgent:");
            sb.AppendLine(hdrs.UserAgent);
            sb.AppendLine();

            sb.AppendLine();
            sb.Append("Server Host Name: ");
            sb.AppendLine(HostName);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("Server IP Addresses:");
            var ips = GetLocalIPAddresses().Select(i => i.ToString());
            sb.AppendLines(ips);
            sb.AppendLine();

            sb.AppendLine();
            sb.AppendLine("Server AppSettings:");
            foreach (var key in ConfigurationManager.AppSettings.AllKeys)
            {
                string value = ConfigurationManager.AppSettings[key];

                sb.AppendFormat("Key: {0} ", key);

                if (key.StartsWith("VCAP_"))
                {
                    try
                    {
                        JObject parsed = JObject.Parse(value);
                        sb.AppendFormat("JSON: {0}", parsed.ToString(Formatting.Indented));
                    }
                    catch
                    {
                        sb.AppendFormat("Value: {0}", value);
                    }
                }
                else
                {
                    sb.AppendFormat("Value: {0}", value);
                }
//.........这里部分代码省略.........
开发者ID:hellojais,项目名称:ironfoundry,代码行数:101,代码来源:HelloModule.cs

示例7: TestAppendLinesNulls

 public void TestAppendLinesNulls()
 {
     var sB = new StringBuilder();
     sB.AppendLines("a", null, "c");
 }
开发者ID:drbatty,项目名称:c-sharp-extensions,代码行数:5,代码来源:StringBuilderExtensionsTests.cs


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