Look at the StringBuilder class.  Anytime you are doing string
manipulation/building, StringBuilder is the way to go.  Remember...String is
immutable so each time you change one, you are actually creating a new
String object and forcing the GC of the old one.

J. Keith Wedinger
Senior Software Developer
Sterling Commerce
[EMAIL PROTECTED]


-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Nischal Chitta
Sent: Wednesday, April 17, 2002 1:49 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] String.Insert() not working!!


Hi All

Here is a very simple question. I have a string like the following:

string strTest = "This is a test sentence for testing the string insert
method";

I have predefined postions say like 6, 25,29 which are the starting
positions of is,for,testing.

I want to replace these words that start at this position with:

was,is,test

I tried to use

strTest.Insert(6,"was");
strTest.Insert(25,"is");
strTest.Insert(29,"test");

But it looks like the insert method doesnt work. Can someone show me a
better way of doing this.

Appreciate any help.

Thanks
Nischal

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to