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


C# StringBuilder.TrimEnd方法代码示例

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


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

示例1: TriemEndTest

 public void TriemEndTest()
 {
     StringBuilder sb;
     sb = new StringBuilder("asdfgef");
     Assert.Equal(sb.TrimEnd('a').ToString(), "asdfgef");
     Assert.Equal(sb.TrimEnd('f').ToString(), "asdfge");
     sb.Append("   ");
     Assert.Equal(sb.TrimEnd().ToString(), "asdfge");
     Assert.Equal(sb.TrimEnd(new[] { 'g', 'e' }).ToString(), "asdf");
     Assert.Equal(sb.TrimEnd("asdf").ToString(), string.Empty);
 }
开发者ID:donnieyoung,项目名称:osharp,代码行数:11,代码来源:StringBuilderExtensionsTest.cs

示例2: ToString

    internal string ToString(string sufix)
    {
        StringBuilder info = new StringBuilder();

        info.AppendFormat("Name: {0} {1}", this.FirstName, this.LastName).AppendLine();
        info.AppendLine(sufix).Replace(Environment.NewLine, Environment.NewLine + SuffixIndentation);
        return info.TrimEnd().ToString();
    }
开发者ID:pepakam,项目名称:TelerikAcademy,代码行数:8,代码来源:Human.cs

示例3: ToString

    public override string ToString()
    {
        StringBuilder info = new StringBuilder();

        info.AppendLine("# School: " + this.Name);
        info.AppendLine(this.classes.ToString<Class>());

        return info.TrimEnd().ToString();
    }
开发者ID:dgrigorov,项目名称:TelerikAcademy-1,代码行数:9,代码来源:School.cs

示例4: ToString

    public override string ToString()
    {
        StringBuilder info = new StringBuilder();

        info.AppendLine(base.ToString());

        info.AppendLine(this.disciplines.ToString<Discipline>());

        return info.TrimEnd().ToString();
    }
开发者ID:dgrigorov,项目名称:TelerikAcademy-1,代码行数:10,代码来源:Teacher.cs

示例5: ToString

        public override string ToString()
        {
            if (string.IsNullOrEmpty(TableName))
                throw new ArgumentException("TableName must be set.");

            var sb = new StringBuilder("INSERT INTO ");
            AddTableInfo(sb, SchemaName, TableName);
            sb.Append(" (");

            Columns.ForEach(c => sb.AppendFormat(QUOTE_FORMAT, c).Append(","));
            sb.TrimEnd(',');

            sb.Append(") VALUES (");
            Columns.ForEach(c => sb.AppendFormat(PARAM_FORMAT, c).Append(","));
            sb.TrimEnd(',');

            sb.Append(")");

            return sb.ToString();
        }
开发者ID:geofflane,项目名称:zorched-migrations,代码行数:20,代码来源:SqlInsertOperation.cs

示例6: Process

        public void Process(
            XmlReader xmlReader, 
            StringBuilder output,
            ElementProcessContext elementProcessContext)
        {
            if (elementProcessContext.Current.IsPreservingSpace)
            {
                output.Append("</").Append(xmlReader.Name).Append(">");
            }
            else if (elementProcessContext.Current.IsSignificantWhiteSpace && !output.IsNewLine())
            {
                output.Append("</").Append(xmlReader.Name).Append(">");
            }
            else if ((elementProcessContext.Current.ContentType == ContentTypeEnum.None)
                && this.options.RemoveEndingTagOfEmptyElement)
            {
                // Shrink the current element, if it has no content.
                // E.g., <Element>  </Element> => <Element />
                output = output.TrimEnd(' ', '\t', '\r', '\n');

                int bracketIndex = output.LastIndexOf('>');
                output.Insert(bracketIndex, '/');

                if ((output[bracketIndex - 1] != '\t') 
                    && (output[bracketIndex - 1] != ' ')
                    && this.options.SpaceBeforeClosingSlash)
                {
                    output.Insert(bracketIndex, ' ');
                }
            }
            else if ((elementProcessContext.Current.ContentType == ContentTypeEnum.SingleLineTextOnly)
                && !elementProcessContext.Current.IsMultlineStartTag)
            {
                int bracketIndex = output.LastIndexOf('>');

                string text = output.Substring((bracketIndex + 1), (output.Length - bracketIndex - 1)).Trim();

                output.Length = (bracketIndex + 1);
                output.Append(text).Append("</").Append(xmlReader.Name).Append(">");
            }
            else
            {
                string currentIndentString = this.indentService.GetIndentString(xmlReader.Depth);

                if (!output.IsNewLine())
                {
                    output.Append(Environment.NewLine);
                }

                output.Append(currentIndentString).Append("</").Append(xmlReader.Name).Append(">");
            }

            elementProcessContext.Pop();
        }
开发者ID:tmatz,项目名称:XamlStyler,代码行数:54,代码来源:EndElementDocumentProcessor.cs

示例7: ToString

        protected string ToString(string suffix)
        {
            StringBuilder info = new StringBuilder();

            info.AppendFormat("Name: {0} {1}", this.firstName, this.lastName).AppendLine();

            info.AppendLine(suffix).Replace(
                Environment.NewLine, Environment.NewLine
            );

            return info.TrimEnd().ToString();
        }
开发者ID:smihaylovit,项目名称:TelerikHomework,代码行数:12,代码来源:Human.cs

示例8: Process

        public void Process(XmlReader xmlReader, StringBuilder output, ElementProcessContext elementProcessContext)
        {
            if (elementProcessContext.Current.IsPreservingSpace)
            {
                output.Append("</").Append(xmlReader.Name).Append(">");
            }
            else if (elementProcessContext.Current.IsSignificantWhiteSpace && !output.IsNewLine())
            {
                output.Append("</").Append(xmlReader.Name).Append(">");
            }
            // Shrink the current element, if it has no content.
            // E.g., <Element>  </Element> => <Element />
            else if (elementProcessContext.Current.ContentType == ContentTypeEnum.NONE && _options.RemoveEndingTagOfEmptyElement)
            {
                #region shrink element with no content

                output = output.TrimEnd(' ', '\t', '\r', '\n');

                int bracketIndex = output.LastIndexOf('>');
                output.Insert(bracketIndex, '/');

                if (output[bracketIndex - 1] != '\t' && output[bracketIndex - 1] != ' ' && _options.SpaceBeforeClosingSlash)
                {
                    output.Insert(bracketIndex, ' ');
                }

                #endregion shrink element with no content
            }
            else if (elementProcessContext.Current.ContentType == ContentTypeEnum.SINGLE_LINE_TEXT_ONLY && elementProcessContext.Current.IsMultlineStartTag == false)
            {
                int bracketIndex = output.LastIndexOf('>');

                string text = output.Substring(bracketIndex + 1, output.Length - bracketIndex - 1).Trim();

                output.Length = bracketIndex + 1;
                output.Append(text).Append("</").Append(xmlReader.Name).Append(">");
            }
            else
            {
                string currentIndentString = _indentService.GetIndentString(xmlReader.Depth);

                if (!output.IsNewLine())
                {
                    output.Append(Environment.NewLine);
                }

                output.Append(currentIndentString).Append("</").Append(xmlReader.Name).Append(">");
            }

            elementProcessContext.Pop();
        }
开发者ID:NicoVermeir,项目名称:XamlStyler,代码行数:51,代码来源:EndElementDocumentProcessor.cs

示例9: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DataEntities ent = new DataEntities();

                long chapterid = WS.RequestString("cid").ToInt64();
                BookChapter bc = (from l in ent.BookChapter where l.ID == chapterid select l).FirstOrDefault();
                bc.ClickCount = bc.ClickCount > 0 ? bc.ClickCount + 1 : 1;

                ent.SaveChanges();

                ent.Dispose();
                //写入Cookie

                List<Cook> cookies = new List<Cook>();
                if (Voodoo.Cookies.Cookies.GetCookie("history") != null)
                {
                    string[] chapters = Voodoo.Cookies.Cookies.GetCookie("history").Value.Split(',');
                    foreach (string chapter in chapters)
                    {
                        string[] arr_chapter = chapter.Split('|');
                        cookies.Add(new Cook() { id = arr_chapter[0].ToInt64(), time = arr_chapter[1].ToDateTime(), bookid = arr_chapter[2].ToInt32() });
                    }
                }

                cookies = cookies.Where(p => p.bookid != bc.BookID).OrderByDescending(p => p.time).Take(4).ToList();
                cookies.Add(new Cook() { id = chapterid, time = DateTime.Now, bookid=bc.BookID });

                StringBuilder sb = new StringBuilder();

                foreach (Cook c in cookies)
                {
                    sb.Append(string.Format("{0}|{1}|{2},", c.id, c.time.ToString(), c.bookid.ToS()));
                }
                sb = sb.TrimEnd(',');

                HttpCookie _cookie = new HttpCookie("history", sb.ToString());
                _cookie.Expires = DateTime.Now.AddYears(1);

                Voodoo.Cookies.Cookies.SetCookie(_cookie);
            }//end try
            catch
            {
                Voodoo.Cookies.Cookies.Remove("history");
            }
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:47,代码来源:ChapterRead.aspx.cs

示例10: ToString

        public override string ToString()
        {
            if (string.IsNullOrEmpty(TableName))
                throw new ArgumentException("TableName must be set.");

            var sb = new StringBuilder("UPDATE ");
            AddTableInfo(sb, SchemaName, TableName);
            sb.Append(" SET ");

            Columns.IterateOver((i, c) => sb.AppendFormat(UPDATE_FORMAT, c).Append(","));
            sb.TrimEnd(',');

            whereHelper.ClauseBuilder = sb;
            whereHelper.AppendWhere();

            return sb.ToString();
        }
开发者ID:geofflane,项目名称:zorched-migrations,代码行数:17,代码来源:SqlUpdateOperation.cs

示例11: InnerSerialize

        private string InnerSerialize(CfgNode node) {
            var meta = CfgMetadataCache.GetMetadata(node.GetType());
            var builder = new StringBuilder();
            if (meta.All(kv => kv.Value.ListType == null)) {
                builder.Append("{");
                SerializeAttributes(meta, node, builder);
                builder.TrimEnd(", ");
                builder.Append(" }");
            } else {
                builder.AppendLine("{");
                SerializeAttributes(meta, node, builder);
                SerializeElements(meta, node, builder, 1);
                builder.AppendLine();
                builder.Append("}");
            }

            return builder.ToString();
        }
开发者ID:modulexcite,项目名称:Cfg-NET,代码行数:18,代码来源:JsonSerializer.cs

示例12: Next

 private static void Next(StringBuilder sb, int i, int last) {
     if (i < last) {
         sb.TrimEnd(", ");
         sb.Append(" }");
         sb.AppendLine(",");
     } else {
         sb.TrimEnd(", ");
         sb.AppendLine(" }");
     }
 }
开发者ID:modulexcite,项目名称:Cfg-NET,代码行数:10,代码来源:JsonSerializer.cs

示例13: getlink

        /// <summary>
        /// 友情链接
        /// </summary>
        /// <returns></returns>
        public static string getlink(string n)
        {
            using (DataEntities ent = new DataEntities())
            {
                StringBuilder sb = new StringBuilder("");
                var links =// LinkView.GetModelList("id>0 order by [Index]");
                    (from l in ent.Link orderby l.Index select l).ToList();
                foreach (var l in links)
                {
                    sb.AppendLine(string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>|", l.Url, l.LinkTitle));
                }

                return sb.TrimEnd('|').ToString();
            }
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:19,代码来源:Functions.cs

示例14: cmsflashpic

        /// <summary>
        /// 轮播Flash
        /// </summary>
        /// <param name="ClassID"></param>
        /// <param name="count"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="showTitle"></param>
        /// <param name="titleLength"></param>
        /// <param name="interval"></param>
        /// <param name="ExtSql"></param>
        /// <param name="Order"></param>
        /// <returns></returns>
        public static string cmsflashpic(string ClassID, string count, string width, string height, string showTitle, string titleLength, string interval, string ExtSql, string Order)
        {
            DataEntities ent = new DataEntities();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<!--开始FLASH-->");
            sb.AppendLine("<div class=\"flash\">");
            sb.AppendLine("<script type=\"text/javascript\">");
            sb.AppendLine("<!--");

            sb.AppendLine(string.Format("var interval_time={0};", interval));
            sb.AppendLine(string.Format("var focus_width={0};", width));
            sb.AppendLine(string.Format("var focus_height={0};", height));
            if (showTitle.ToInt32() > 0)
            {
                sb.AppendLine("var text_height=20;");
            }
            else
            {
                sb.AppendLine("var text_height=0;");
            }
            sb.AppendLine("var text_align=\"center\";");
            sb.AppendLine("var swf_height = focus_height+text_height;");
            sb.AppendLine("var swfpath=\"/e/data/images/pixviewer.swf\";");
            sb.AppendLine("var swfpatha=\"/e/data/images/pixviewer.swf\";");

            StringBuilder sb_pics = new StringBuilder();
            StringBuilder sb_links = new StringBuilder();
            StringBuilder sb_texts = new StringBuilder();

            #region 图片变量
            sb_pics.Append("var pics=\"");
            sb_links.Append("var links=\"");
            sb_texts.Append("var texts=\"");

            string str_sql = string.Format("(ZtID='{0}' or ClassID='{1}') and len(TitleImage)>0", ClassID, ClassID);
            if (ExtSql.Length > 0)
            {
                str_sql += " and " + ExtSql;
            }
            if (Order.Length > 0)
            {
                str_sql += " order by " + Order;
            }

            List<News> newses = //NewsView.GetModelList(str_sql, count.ToInt32());
                ent.CreateQuery<News>(string.Format("select top {0} * from News where {1}", count, str_sql)).ToList();

            newses = newses.Where(p => p.TitleImage.IndexOf(".gif") < 0).ToList();//不支持GIF文件
            foreach (News n in newses)
            {
                sb_pics.Append(n.TitleImage + "|");
                sb_links.Append(BasePage.GetNewsUrl(n, n.GetClass()) + "|");
                sb_texts.Append(n.Title.CutString(titleLength.ToInt32()) + "|");
            }
            sb_pics = sb_pics.TrimEnd('|');
            sb_links = sb_links.TrimEnd('|');
            sb_texts = sb_texts.TrimEnd('|');

            sb_pics.Append("\";\n");
            sb_links.Append("\";\n");
            sb_texts.Append("\";\n");

            sb.Append(sb_pics.ToString());
            sb.Append(sb_links.ToString());
            sb.Append(sb_texts.ToString());
            #endregion

            #region 输出Flash
            sb.AppendLine("document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"'+ focus_width +'\" height=\"'+ swf_height +'\">'); ");
            sb.AppendLine("document.write('<param name=\"movie\" value=\"'+swfpath+'\"><param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=\"#ffffff\">'); ");
            sb.AppendLine("document.write('<param name=\"menu\" value=\"false\"><param name=wmode value=\"opaque\">'); ");
            sb.AppendLine("document.write('<param name=\"FlashVars\" value=\"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'&text_align='+text_align+'&interval_time='+interval_time+'\">'); ");
            sb.AppendLine("document.write('<embed src=\"'+swfpath+'\" wmode=\"opaque\" FlashVars=\"pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'&text_align='+text_align+'&interval_time='+interval_time+'\" menu=\"false\" bgcolor=\"#ffffff\" quality=\"high\" width=\"'+ focus_width +'\" height=\"'+ swf_height +'\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />');");
            sb.AppendLine("document.write('</object>');");
            #endregion

            sb.AppendLine("//-->");
            sb.AppendLine("</script>");
            sb.AppendLine("</div>");
            ent.Dispose();

            return sb.ToString();
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:97,代码来源:Functions.cs

示例15: GetTableSqlText

        /// <summary>
        /// 获取表的Sql脚本
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public override string GetTableSqlText(SOTable table)
        {
            List<SOColumn> columnnList = table.ColumnList;
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("create table [dbo].[" + table.Name + "] (");
            foreach(SOColumn item in columnnList)
            {
                sb.AppendFormat("\t[{0}] {1}", item.Name, item.NativeType);
                if (item.PrimaryKey)
                {
                    sb.Append(" PRIMARY KEY ");
                }

                if (item.Identify)
                {
                    sb.Append(" identity ");
                }
                else if (!item.Identify)
                {
                    sb.Append(" not null ");

                    if (item.DefaultValue != null && item.DefaultValue != "")
                    {
                        sb.Append(" default " + item.DefaultValue);
                    }
                }

                sb.Append(",\r\n");
            }

            sb = sb.TrimEnd(",\r\n");
            sb.AppendLine("\r\n)");
            return sb.ToString() ;
        }
开发者ID:EvanYaoPeng,项目名称:Kalman.Studio,代码行数:39,代码来源:SqlServerSchema.cs


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