StringBuilder.Remove(Int32, Int32) 메서드

정의

이 인스턴스에서 지정된 문자 범위를 제거합니다.Removes the specified range of characters from this instance.

public:
 System::Text::StringBuilder ^ Remove(int startIndex, int length);
public System.Text.StringBuilder Remove (int startIndex, int length);
member this.Remove : int * int -> System.Text.StringBuilder
Public Function Remove (startIndex As Integer, length As Integer) As StringBuilder

매개 변수

startIndex
Int32

이 인스턴스 내에서 제거를 시작할 0에서 시작하는 위치입니다.The zero-based position in this instance where removal begins.

length
Int32

제거할 문자 수입니다.The number of characters to remove.

반환

삭제 작업이 완료된 후 이 인스턴스에 대한 참조입니다.A reference to this instance after the excise operation has completed.

예외

startIndex 또는 length가 0보다 작거나 startIndex + length가 이 인스턴스의 길이보다 큽니다.If startIndex or length is less than zero, or startIndex + length is greater than the length of this instance.

예제

다음 예제는 Remove 메서드.The following example demonstrates the Remove method.

using namespace System;
using namespace System::Text;
int main()
{
   String^ rule1 = "0----+----1----+----2----+----3----+----4---";
   String^ rule2 = "01234567890123456789012345678901234567890123";
   String^ str = "The quick brown fox jumps over the lazy dog.";
   StringBuilder^ sb = gcnew 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 );
   Console::WriteLine();
   sb->Remove( 10, 6 ); // Remove "brown "
   Console::WriteLine( "New value:" );
   Console::WriteLine( rule1 );
   Console::WriteLine( rule2 );
   Console::WriteLine( "{0}", sb );
}

/*
This example produces the following results:

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.

*/
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());
    }
}
/*
This example produces the following results:

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.

*/
Imports System.Text

Class Sample
   Public Shared Sub Main()
      Dim rule1 As String = "0----+----1----+----2----+----3----+----4---"
      Dim rule2 As String = "01234567890123456789012345678901234567890123"
      Dim str As String   = "The quick brown fox jumps over the lazy dog."
      Dim sb As 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())
   End Sub
End Class
'
'This example produces the following results:
'
'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.
'

설명

현재 메서드는 현재 인스턴스에서 지정된 된 범위의 문자를 제거합니다.The current method removes the specified range of characters from the current instance. 에 있는 문자 (startIndex + length)으로 이동 됩니다 startIndex, 및 현재 인스턴스의 문자열 값으로 단축 됩니다 length합니다.The characters at (startIndex + length) are moved to startIndex, and the string value of the current instance is shortened by length. 현재 인스턴스의 용량을 받지 않습니다.The capacity of the current instance is unaffected.

참고

합니다 Remove 현재 값을 수정 하는 메서드 StringBuilder 인스턴스 및 해당 인스턴스를 반환 합니다.The Remove method modifies the value of the current StringBuilder instance and returns that instance. 만들기 및 새 반환 되지 않습니다 StringBuilder 개체입니다.It does not create and return a new StringBuilder object.

적용 대상

추가 정보