本文整理汇总了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();
}
示例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);
}
}