Inserting, Removing, and Replacing
You can insert a string into another using the
Insert( )
method, shown here:
public string Insert(int
start
, string
str
)
Here,
str
is inserted into the invoking string at the index specified by
start.
The resulting
string is returned.
You can remove a portion of a string using
Remove( )
, shown next:
public string Remove(int
start
)
public string Remove(int
start
, int
count
)
The first form begins at the index specified by
start
and removes all remaining characters
in the string. The second form begins at count and removes
count
number of characters. In
both cases, the resulting string is returned.
You can replace a portion of a string by using
Replace( )
. It has these forms:
public string Replace(char
ch1
, char
ch2
)
public string Replace(string
str1
, string
str2
)
The first form replaces all occurrences of
ch1
in the invoking string with
ch2.
The second
form replaces all occurrences of
str1
in the invoking string with
str2.
In both cases, the
resulting string is returned.
www.freepdf-books.com
Do'stlaringiz bilan baham: |