本文整理匯總了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);
}
}