本文整理汇总了C#中System.Text.StringBuilder.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.Remove方法的具体用法?C# StringBuilder.Remove怎么用?C# StringBuilder.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Text;
class Sample
{
public static void Main()
{
string rule1 = "0----+----1----+----2----+----3----+----4---";
string rule2 = "01234567890123456789012345678901234567890123";
string str = "The quick brown fox jumps over the lazy dog.";
StringBuilder sb = new StringBuilder(str);
Console.WriteLine();
Console.WriteLine("StringBuilder.Remove method");
Console.WriteLine();
Console.WriteLine("Original value:");
Console.WriteLine(rule1);
Console.WriteLine(rule2);
Console.WriteLine("{0}", sb.ToString());
Console.WriteLine();
sb.Remove(10, 6); // Remove "brown "
Console.WriteLine("New value:");
Console.WriteLine(rule1);
Console.WriteLine(rule2);
Console.WriteLine("{0}", sb.ToString());
}
}
输出:
StringBuilder.Remove method Original value: 0----+----1----+----2----+----3----+----4--- 01234567890123456789012345678901234567890123 The quick brown fox jumps over the lazy dog. New value: 0----+----1----+----2----+----3----+----4--- 01234567890123456789012345678901234567890123 The quick fox jumps over the lazy dog.
示例2: Main
//引入命名空间
using System;
using System.Text;
class UseSBApp {
static void Main(string[] args) {
StringBuilder sb = new StringBuilder("Pineapple");
sb.Replace('e', 'X');
sb.Insert(4, "Banana");
sb.Append("Kiwi");
sb.AppendFormat(", {0}:{1}", 123, 45.6789);
sb.Remove(sb.Length - 3, 3);
Console.WriteLine(sb);
}
}