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


C# StringBuilder.Replace方法代码示例

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


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

示例1: GetUpdateCommand

		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(position_x != null)
			{
				sb.AppendLine("`position_x`='" + ((Decimal)position_x.Value).ToString() + "'");
			}
			if(position_y != null)
			{
				sb.AppendLine("`position_y`='" + ((Decimal)position_y.Value).ToString() + "'");
			}
			if(position_z != null)
			{
				sb.AppendLine("`position_z`='" + ((Decimal)position_z.Value).ToString() + "'");
			}
			if(orientation != null)
			{
				sb.AppendLine("`orientation`='" + ((Decimal)orientation.Value).ToString() + "'");
			}
			if(spawntimesecs != null)
			{
				sb.AppendLine("`spawntimesecs`='" + spawntimesecs.Value.ToString() + "'");
			}
			if(comment != null)
			{
				sb.AppendLine("`comment`='" + comment.ToSQL() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `id`='" + id.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:34,代码来源:creature_ai_summons.cs

示例2: WriteAsync

        public async void WriteAsync(DataTable data, string outputFile)
        {
            StringBuilder fileContent = new StringBuilder();

            foreach (var col in data.Columns)
            {
                fileContent.Append("\"" + col.ToString() + "\";");
            }

            fileContent.Replace(";", System.Environment.NewLine, fileContent.Length - 1, 1);



            foreach (DataRow dr in data.Rows)
            {

                foreach (var column in dr.ItemArray)
                {
                    fileContent.Append("\"" + column.ToString() + "\";");
                }

                fileContent.Replace(";", System.Environment.NewLine, fileContent.Length - 1, 1);
            }

            await Task.Run(() => System.IO.File.WriteAllText(outputFile, fileContent.ToString(), Encoding.Unicode));

        }
开发者ID:exxoff,项目名称:AceMoneyImport,代码行数:27,代码来源:CsvFileWriter.cs

示例3: ToCsv

        public static string ToCsv(this DataTable dataTable)
        {
            var sbData = new StringBuilder();

            // Only return Null if there is no structure.
            if (dataTable.Columns.Count == 0)
                return null;

            foreach (var col in dataTable.Columns)
            {
                if (col == null)
                    sbData.Append(",");
                else
                    sbData.Append("\"" + col.ToString().Replace("\"", "\"\"") + "\",");
            }

            sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);

            foreach (DataRow dr in dataTable.Rows)
            {
                foreach (var column in dr.ItemArray)
                {
                    if (column == null)
                        sbData.Append(",");
                    else
                        sbData.Append("\"" + column.ToString().Replace("\"", "\"\"") + "\",");
                }
                sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);
            }

            return sbData.ToString();
        }
开发者ID:votrongdao,项目名称:DaxStudio,代码行数:32,代码来源:DataSetExtensions.cs

示例4: files

        /*	Write a program that replaces all occurrences of the sub-string start with the sub-string
        finish in a text file.
            Ensure it will work with large files (e.g. 100 MB).*/
        static void Main()
        {
            string path = "test.txt";
            StringBuilder builder = new StringBuilder();

            try
            {
                StreamReader reader = new StreamReader(path);

                using (reader)
                {
                    string line = reader.ReadLine();

                    while (line != null)
                    {
                        builder.AppendLine(line);
                        line = reader.ReadLine();
                    }

                    reader.Close();
                }

                builder = builder.Replace("start", "finish");
                builder = builder.Replace("Start", "Finish");

                WriteToFile(builder, path);

                Console.WriteLine(builder.ToString());
            }
            catch (Exception)
            {
                Console.WriteLine("Error! File can not be found!");
            }
        }
开发者ID:theshaftman,项目名称:Telerik-Academy,代码行数:37,代码来源:ReplaceSubstring.cs

示例5: GetUpdateCommand

        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(path_rotation0 != null)
            {
                sb.AppendLine("`path_rotation0`='" + ((Decimal)path_rotation0.Value).ToString() + "'");
            }
            if(path_rotation1 != null)
            {
                sb.AppendLine("`path_rotation1`='" + ((Decimal)path_rotation1.Value).ToString() + "'");
            }
            if(path_rotation2 != null)
            {
                sb.AppendLine("`path_rotation2`='" + ((Decimal)path_rotation2.Value).ToString() + "'");
            }
            if(path_rotation3 != null)
            {
                sb.AppendLine("`path_rotation3`='" + ((Decimal)path_rotation3.Value).ToString() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `guid`='" + guid.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
开发者ID:devmaximus,项目名称:MaximusParserX,代码行数:26,代码来源:gameobject_addon.cs

示例6: Generate_SVC

 internal static string Generate_SVC(string pServiceName, string prjName)
 {
     StringBuilder wClassContainer = new StringBuilder(_SVC_tt);
     wClassContainer.Replace(CommonConstants.CONST_SERVICE_NAME, pServiceName);
     wClassContainer.Replace(CommonConstants.CONST_FwkProject_NAME, prjName);
     return wClassContainer.ToString();
 }
开发者ID:gpanayir,项目名称:sffwk,代码行数:7,代码来源:GenSVCr.cs

示例7: GenMethodReturn

        private static string GenMethodReturn(Table pTable, MethodActionType t)
        {
            StringBuilder wBuilderReturn = null;
            switch (t)
            {
                case MethodActionType.Insert:
                    {
                        Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable);
                        if (pPK != null)
                        {
                            wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("InsertReturn").Content);
                            wBuilderReturn.Replace(CommonConstants.CONST_ENTITY_PROPERTY_NAME, pPK.Name);
                            wBuilderReturn.Replace(CommonConstants.CONST_TYPENAME, FwkGeneratorHelper.GetCSharpType(pPK));

                            return wBuilderReturn.ToString();
                        }
                        else
                            return "  wDataBase.ExecuteNonQuery(wCmd);";
                    }
                case MethodActionType.Update:
                    return "  wDataBase.ExecuteNonQuery(wCmd);";

                case MethodActionType.SearchByParam:

                    wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("SearchReturn").Content);

                    return wBuilderReturn.ToString();
                case MethodActionType.Delete:
                    return  "  wDataBase.ExecuteNonQuery(wCmd);";

            }

            return string.Empty;

        }
开发者ID:gpanayir,项目名称:sffwk,代码行数:35,代码来源:GenDAC.cs

示例8: RegisterClientScripts

        protected override void RegisterClientScripts()
        {
            base.RegisterClientScripts();

            //Style Sheet
            LiteralControl include = new LiteralControl("<link href='css/YUI/calendar.css' rel='stylesheet' type='text/css' />");
            this.Page.Header.Controls.Add(include);

            //scripts
            //RegisterIncludeScript("QueryBuilder", "Sage.SalesLogix.Client.GroupBuilder.jscript.querybuilder.js", true);
            RegisterIncludeScript("Yahoo_yahoo", "jscript/YUI/yahoo.js", false);
            RegisterIncludeScript("Yahoo_event", "jscript/YUI/event.js", false);
            RegisterIncludeScript("TimeObject", "jscript/timeobjs.js", false);

            if (!Page.ClientScript.IsClientScriptBlockRegistered("QBAddCondition"))
            {
                string vScript = ScriptHelper.UnpackEmbeddedResourceToString("jscript.QBAddCondition.js");
                StringBuilder vJS = new StringBuilder(vScript);

                vJS.Replace("@DateValueClientID", DateValue.ClientID + "_TXT");
                vJS.Replace("@DateValueFormat", DateValue.DateFormat);

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "QBAddCondition", vJS.ToString(), true);
            }
        }
开发者ID:ssommerfeldt,项目名称:TAC_MAT,代码行数:25,代码来源:QBAddCondition.ascx.cs

示例9: MakeFlvHtml

        /// <summary>
        /// 生成播放Flv格式文件的HTML代码
        /// </summary>
        /// <param name="url">Flv格式文件的URL</param>
        /// <param name="width">播放控件的显示宽度</param>
        /// <param name="height">播放控件的显示高度</param>
        /// <returns></returns>
        public static string MakeFlvHtml(string url, int width, int height)
        {
            string fileName = AppPath.CurrentAppPath() + "content\\FlashTemplate.txt";
            var objReader = new StreamReader(fileName);
            string sLine = "";
            var arrText = new ArrayList();
            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                    arrText.Add(sLine);
            }
            objReader.Close();

            var buff = new StringBuilder();
            foreach (string sOutput in arrText)
            {
                buff.Append(sOutput);
                buff.Append(Environment.NewLine);
            }
            buff.Replace("{source}", url);
            buff.Replace("{width}", width + "");
            buff.Replace("{height}", height + "");

            return buff.ToString();
        }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:33,代码来源:VideoHelper.cs

示例10: SanitizeHTML

        public string SanitizeHTML(string content)
        {
            // Check to see if the incoming contant contains <script> or </script>.
            // These are unsafe HTML tags.
            var tag1 = "<script>";
            var tag2 = "</script>";

            if (content.Contains(tag1) || content.Contains(tag2))
            {
                var sanitize = new StringBuilder(content);

                // The Replace() Method replaces within a substring of an instance all occurances of a specified character
                // with another character
                sanitize.Replace("<script>", "&lt;script&gt;");
                sanitize.Replace("</script>", "&lt/script&gt;");

                // The 'sanitize' is an object of the class Stringbuilder. In order to return a string to the
                // Main method, perform the ToString() method on the object 'sanitize'.
                var result = sanitize.ToString();

                //Assert Assumption that sanitize.ToString() in fact changed
                Debug.Assert(result is string, "The variable 'result' is not a string");
                return result;
            }

            // If the content does not contain any harmful HTML tags, return the content unchanged
            return content;
        }
开发者ID:nfwaldron,项目名称:CoderCamps-Projects,代码行数:28,代码来源:Security.cs

示例11: GetBytes

 public static byte[] GetBytes(string pkt)
 {
     var r = new StringReader(pkt);
     var sb = new StringBuilder();
     string str;
     while((str = r.ReadLine()) != null) {
         int i = 0;
         try {
             i = Convert.ToInt32(str.Substring(0, 4), 16);
         }
         catch {
         }
         if(i == 0) {
             if(sb.Length > 0) {
                 sb.Replace(" ", "").Replace("-", "").Replace("\r", "").Replace("|", "");
                 return HexToBytes(sb.ToString());
             }
             sb.Length = 0;
         }
         string[] strArr3 = str.Split(':');
         if(strArr3.Length > 2) {
             sb.Append(strArr3[1]);
         }
     }
     if(sb.Length > 0) {
         sb.Replace(" ", "").Replace("-", "").Replace("\r", "").Replace("|", "");
         return HexToBytes(sb.ToString());
     }
     return null;
 }
开发者ID:hazzik,项目名称:uwow2,代码行数:30,代码来源:PacketsHelper.cs

示例12: ReplaceHtmlEscapes

 static StringBuilder ReplaceHtmlEscapes(StringBuilder sb)
 {
     sb = sb.Replace("\"", "&quot;");
     sb = sb.Replace("<", "&lt;");
     sb = sb.Replace(">", "&gt;");
     return sb;
 }
开发者ID:CNH-Hyper-Extractive,项目名称:parallel-sdk,代码行数:7,代码来源:WikiSyntax.cs

示例13: GetUpdateCommand

		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(spell_id != null)
			{
				sb.AppendLine("`spell_id`='" + spell_id.Value.ToString() + "'");
			}
			if(quest_start != null)
			{
				sb.AppendLine("`quest_start`='" + quest_start.Value.ToString() + "'");
			}
			if(quest_start_active != null)
			{
				sb.AppendLine("`quest_start_active`='" + quest_start_active.Value.ToString() + "'");
			}
			if(quest_end != null)
			{
				sb.AppendLine("`quest_end`='" + quest_end.Value.ToString() + "'");
			}
			if(cast_flags != null)
			{
				sb.AppendLine("`cast_flags`='" + cast_flags.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `npc_entry`='" + npc_entry.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:30,代码来源:npc_spellclick_spells.cs

示例14: GetUpdateCommand

        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(parent != null)
            {
                sb.AppendLine("`parent`='" + parent.Value.ToString() + "'");
            }
            if(levelmin != null)
            {
                sb.AppendLine("`levelmin`='" + levelmin.Value.ToString() + "'");
            }
            if(levelmax != null)
            {
                sb.AppendLine("`levelmax`='" + levelmax.Value.ToString() + "'");
            }
            if(scriptname != null)
            {
                sb.AppendLine("`scriptname`='" + scriptname.ToSQL() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `map`='" + map.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
开发者ID:devmaximus,项目名称:MaximusParserX,代码行数:26,代码来源:instance_template.cs

示例15: GetUpdateCommand

        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(prev_spell != null)
            {
                sb.AppendLine("`prev_spell`='" + prev_spell.Value.ToString() + "'");
            }
            if(first_spell != null)
            {
                sb.AppendLine("`first_spell`='" + first_spell.Value.ToString() + "'");
            }
            if(rank != null)
            {
                sb.AppendLine("`rank`='" + rank.Value.ToString() + "'");
            }
            if(req_spell != null)
            {
                sb.AppendLine("`req_spell`='" + req_spell.Value.ToString() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `spell_id`='" + spell_id.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
开发者ID:devmaximus,项目名称:MaximusParserX,代码行数:26,代码来源:spell_chain.cs


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