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