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


C# StringBuilder.Remove方法代码示例

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


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

示例1: SerializeArrayAsString

 /// <summary>
 /// Serialize the array elements as item1,item2,item3
 /// </summary>
 public static string SerializeArrayAsString(IList list)
 {
     System.StringBuilder txt = new System.StringBuilder();
     foreach (var item in list)
         txt.Append("\"{0}\",", item);
     if (txt.Length > 0)
         txt.Remove(txt.Length - 1,1);
     return txt.ToString();
 }
开发者ID:priestofpsi,项目名称:theDiary-Common-Framework,代码行数:12,代码来源:Utility.cs

示例2: Save

        /// <summary>
        /// Save the output to the given file
        /// If the file already exists, don't overwrite it
        /// </summary>
        /// <param name="fileName"></param>
        public static void Save(string fileName)
        {
            try
            {
                string configFile = GetConfigFileName(fileName);

#if REPLACEORIGINAL
            StringBuilder original = new StringBuilder();
            
            string str;
            // read the original file
            using (StreamReader sr = new StreamReader(configFile))
                str = sr.ReadToEnd();

            original.Append(str);
            // find the delimeters and delete the old configuration
            int start = str.IndexOf(Resources.Configuration_StartDelimeter);
            if (start >= 0)
            {
                int end = str.LastIndexOf(Resources.Configuration_EndDelimeter) + Resources.Configuration_EndDelimeter.Length;
                original.Remove(start, end - start);
            }
            else
            {
                start = str.IndexOf("<xs:schema");
            }

            // insert the new configuration
            string config = Output();
            original.Insert(start, config);

            // write it out
            using (StreamWriter sw = new StreamWriter(configFile, false))
                sw.Write(original.ToString());
#else
                if (!File.Exists(configFile))
                    Serializer.SerializeToFile<Configuration>(m_configuration, configFile);

#endif
            }
            catch (Exception ex)
            {
                string message = string.Format("Error saving XmlToClasses configuration file {0}. See Inner Exception below for details", fileName);
                throw new Exception(message, ex);
            }
        }
开发者ID:nujmail,项目名称:xsd-to-classes,代码行数:51,代码来源:Configuration.cs


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