By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

String.Replace( ) vs. StringBuilder.Replace( )

P: n/a
Hi,

I know this has been asked before, but reading the threads it is still not
entirely clear.
Deciding which .Replace( ) to use when.

Typically if I create a string in a loop I always use a StringBuilder. At
present I am
porting a VB6 webclass app to VB.NET and therefore I am trying to make it as
efficent as possible via the new functionality of VB.NET.

At present I have (in various places):
variableX = variableX.Replace("a string", "another string")

In some cases the above variableX will have 4+ replaces virutally one after
the
other with 1 or 2 of the replacement strings having length > 100.

This seems like the perfect candidate for StringBuilder.Replace instead of
String.Replace
what does anybody think?

Regards,
Pete
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi,

When you use variableX = variableX.Replace("a string", "another
string") with a string it will it will create a new string in memory and
destroy the old one. The stringbuilder will reuse the memory space
therefore it is quicker.

http://msdn.microsoft.com/library/de...ilderclass.asp

Ken
----------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
Hi,

I know this has been asked before, but reading the threads it is still not
entirely clear.
Deciding which .Replace( ) to use when.

Typically if I create a string in a loop I always use a StringBuilder. At
present I am
porting a VB6 webclass app to VB.NET and therefore I am trying to make it
as
efficent as possible via the new functionality of VB.NET.

At present I have (in various places):
variableX = variableX.Replace("a string", "another string")

In some cases the above variableX will have 4+ replaces virutally one
after
the
other with 1 or 2 of the replacement strings having length > 100.

This seems like the perfect candidate for StringBuilder.Replace instead of
String.Replace
what does anybody think?

Regards,
Pete

Nov 20 '05 #2

P: n/a
Hi,

The link provided gives a lot of info but leaves out some important info
hence the original question.

If I have a stringbuilder and lets say it has length = 100, I also have
strHeaderStuff with length = 200.
For the sake of argument lets also say that .IndexOf("<head>") is 25 and I
say:

MyStrBldr.Replace("<head>", strHeaderStuff)

The stringbuilder object is increasing it's size and inserting at a position
it has to find first.
So I still need to be convinced that doing it this way will be faster than
doing:

SimpleString = SimpleString.Replace("<head>", strHeaderStuff)

I don't wanna start a massive flaming debate about the rights and wrongs of
anything but...
wouldn't it of made more sense for MS to implement the String type to do the
same as a
StringBuilder under the covers and hence not have StringBuilder?

i.e
Dim str As String
Str = "Hello"
Str &= " World"

Is roughly the same as saying:
Dim sbr As New StringBuilder
sbr.Append("Hello")
sbr.Append(" World")

So if the stringbuilder is so much more efficent why not simply implement
the String that way
in the first place?

Regards,
Peter

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
Hi,

When you use variableX = variableX.Replace("a string", "another
string") with a string it will it will create a new string in memory and
destroy the old one. The stringbuilder will reuse the memory space
therefore it is quicker.

http://msdn.microsoft.com/library/de...ilderclass.asp
Ken
----------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
Hi,

I know this has been asked before, but reading the threads it is still not entirely clear.
Deciding which .Replace( ) to use when.

Typically if I create a string in a loop I always use a StringBuilder. At present I am
porting a VB6 webclass app to VB.NET and therefore I am trying to make it as
efficent as possible via the new functionality of VB.NET.

At present I have (in various places):
variableX = variableX.Replace("a string", "another string")

In some cases the above variableX will have 4+ replaces virutally one
after
the
other with 1 or 2 of the replacement strings having length > 100.

This seems like the perfect candidate for StringBuilder.Replace instead of String.Replace
what does anybody think?

Regards,
Pete


Nov 20 '05 #3

P: n/a
Cor
Hi Peter,

Only an answer on your question,

I asume that making a string as dim mystring as String = "Peter" with the
stringbuilder is a little bit overdone.

But nobody is keeping you from doing it with stringbuilder, that is what I
find so nice from VB.net, you can make your own decissions how you do it.

When that is gone you can take a tool as Access.

But just my thought,
Cor
Nov 20 '05 #4

P: n/a
Hi,

The stringbuilder will only resize if the string is larger.

Ken
---------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Hi,

The link provided gives a lot of info but leaves out some important info
hence the original question.

If I have a stringbuilder and lets say it has length = 100, I also have
strHeaderStuff with length = 200.
For the sake of argument lets also say that .IndexOf("<head>") is 25 and I
say:

MyStrBldr.Replace("<head>", strHeaderStuff)

The stringbuilder object is increasing it's size and inserting at a
position
it has to find first.
So I still need to be convinced that doing it this way will be faster than
doing:

SimpleString = SimpleString.Replace("<head>", strHeaderStuff)

I don't wanna start a massive flaming debate about the rights and wrongs
of
anything but...
wouldn't it of made more sense for MS to implement the String type to do
the
same as a
StringBuilder under the covers and hence not have StringBuilder?

i.e
Dim str As String
Str = "Hello"
Str &= " World"

Is roughly the same as saying:
Dim sbr As New StringBuilder
sbr.Append("Hello")
sbr.Append(" World")

So if the stringbuilder is so much more efficent why not simply implement
the String that way
in the first place?

Regards,
Peter

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
Hi,

When you use variableX = variableX.Replace("a string", "another
string") with a string it will it will create a new string in memory and
destroy the old one. The stringbuilder will reuse the memory space
therefore it is quicker.

http://msdn.microsoft.com/library/de...ilderclass.asp

Ken
----------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I know this has been asked before, but reading the threads it is still not > entirely clear.
> Deciding which .Replace( ) to use when.
>
> Typically if I create a string in a loop I always use a StringBuilder. At > present I am
> porting a VB6 webclass app to VB.NET and therefore I am trying to make it > as
> efficent as possible via the new functionality of VB.NET.
>
> At present I have (in various places):
> variableX = variableX.Replace("a string", "another string")
>
> In some cases the above variableX will have 4+ replaces virutally one
> after
> the
> other with 1 or 2 of the replacement strings having length > 100.
>
> This seems like the perfect candidate for StringBuilder.Replace instead of > String.Replace
> what does anybody think?
>
> Regards,
> Pete
>
>



Nov 20 '05 #5

P: n/a
Hi,

Eh? I don't get what you are saying?

If I have a SBuilder with length 100 and I replace "<head>" (length 6) with
a string
that is 200 in length then the Sbuilder has no choice but to resize surely;
because
you are replacing 6 out of 100 with 200 hence the length after the replace
would be
294 which is 194 larger than before the operation??

Therefore since it is resizing it then you'd assume there is some overhead
to that.
So how does that overhead compare to doing a :
Str = Str.Replace("<head>", str2)

Regards,
Peter
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

The stringbuilder will only resize if the string is larger.

Ken
---------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Hi,

The link provided gives a lot of info but leaves out some important info
hence the original question.

If I have a stringbuilder and lets say it has length = 100, I also have
strHeaderStuff with length = 200.
For the sake of argument lets also say that .IndexOf("<head>") is 25 and I
say:

MyStrBldr.Replace("<head>", strHeaderStuff)

The stringbuilder object is increasing it's size and inserting at a
position
it has to find first.
So I still need to be convinced that doing it this way will be faster than doing:

SimpleString = SimpleString.Replace("<head>", strHeaderStuff)

I don't wanna start a massive flaming debate about the rights and wrongs
of
anything but...
wouldn't it of made more sense for MS to implement the String type to do
the
same as a
StringBuilder under the covers and hence not have StringBuilder?

i.e
Dim str As String
Str = "Hello"
Str &= " World"

Is roughly the same as saying:
Dim sbr As New StringBuilder
sbr.Append("Hello")
sbr.Append(" World")

So if the stringbuilder is so much more efficent why not simply implement the String that way
in the first place?

Regards,
Peter

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
Hi,

When you use variableX = variableX.Replace("a string", "another
string") with a string it will it will create a new string in memory and destroy the old one. The stringbuilder will reuse the memory space
therefore it is quicker.

http://msdn.microsoft.com/library/de...ilderclass.asp

Ken
----------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I know this has been asked before, but reading the threads it is

still not
> entirely clear.
> Deciding which .Replace( ) to use when.
>
> Typically if I create a string in a loop I always use a
StringBuilder. At
> present I am
> porting a VB6 webclass app to VB.NET and therefore I am trying to
make it
> as
> efficent as possible via the new functionality of VB.NET.
>
> At present I have (in various places):
> variableX = variableX.Replace("a string", "another string")
>
> In some cases the above variableX will have 4+ replaces virutally one
> after
> the
> other with 1 or 2 of the replacement strings having length > 100.
>
> This seems like the perfect candidate for StringBuilder.Replace
instead of
> String.Replace
> what does anybody think?
>
> Regards,
> Pete
>
>



Nov 20 '05 #6

P: n/a
Hi,

The point I was making was that since when dealing with Strings that are
appended
and replaced over and over the stringbuilder is more efficent then why
bother
making the distinction.

All it does is give you a pointless decision which in some cases is very
close.
It boils down to this:
Do you want your app to run fast/efficently or run okay/more-or-less
efficent?

Well I would always choose fast/efficently as I'm sure most people would,
therefore
why complicate the issue by having String and StringBuilder? Why not just
have
String which works like StringBuilder under the covers?

Finally don't be so digusting!!! Mentioning MS Access, urrgghh!

Regards,
Peter
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Peter,

Only an answer on your question,

I asume that making a string as dim mystring as String = "Peter" with the
stringbuilder is a little bit overdone.

But nobody is keeping you from doing it with stringbuilder, that is what I
find so nice from VB.net, you can make your own decissions how you do it.

When that is gone you can take a tool as Access.

But just my thought,
Cor

Nov 20 '05 #7

P: n/a
Hi,

I guess in that case there would be no real improvement.

Ken
-----------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Hi,

Eh? I don't get what you are saying?

If I have a SBuilder with length 100 and I replace "<head>" (length 6)
with
a string
that is 200 in length then the Sbuilder has no choice but to resize
surely;
because
you are replacing 6 out of 100 with 200 hence the length after the replace
would be
294 which is 194 larger than before the operation??

Therefore since it is resizing it then you'd assume there is some overhead
to that.
So how does that overhead compare to doing a :
Str = Str.Replace("<head>", str2)

Regards,
Peter
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

The stringbuilder will only resize if the string is larger.

Ken
---------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> The link provided gives a lot of info but leaves out some important
> info
> hence the original question.
>
> If I have a stringbuilder and lets say it has length = 100, I also have
> strHeaderStuff with length = 200.
> For the sake of argument lets also say that .IndexOf("<head>") is 25
> and I > say:
>
> MyStrBldr.Replace("<head>", strHeaderStuff)
>
> The stringbuilder object is increasing it's size and inserting at a
> position
> it has to find first.
> So I still need to be convinced that doing it this way will be faster than > doing:
>
> SimpleString = SimpleString.Replace("<head>", strHeaderStuff)
>
> I don't wanna start a massive flaming debate about the rights and
> wrongs
> of
> anything but...
> wouldn't it of made more sense for MS to implement the String type to
> do
> the
> same as a
> StringBuilder under the covers and hence not have StringBuilder?
>
> i.e
> Dim str As String
> Str = "Hello"
> Str &= " World"
>
> Is roughly the same as saying:
> Dim sbr As New StringBuilder
> sbr.Append("Hello")
> sbr.Append(" World")
>
> So if the stringbuilder is so much more efficent why not simply implement > the String that way
> in the first place?
>
> Regards,
> Peter
>
> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
> news:OA**************@TK2MSFTNGP12.phx.gbl...
>> Hi,
>>
>> When you use variableX = variableX.Replace("a string",
>> "another
>> string") with a string it will it will create a new string in memory and >> destroy the old one. The stringbuilder will reuse the memory space
>> therefore it is quicker.
>>
>>
> http://msdn.microsoft.com/library/de...ilderclass.asp >>
>> Ken
>> ----------------------
>> "Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
>> news:eV**************@TK2MSFTNGP09.phx.gbl...
>> > Hi,
>> >
>> > I know this has been asked before, but reading the threads it is still > not
>> > entirely clear.
>> > Deciding which .Replace( ) to use when.
>> >
>> > Typically if I create a string in a loop I always use a StringBuilder. > At
>> > present I am
>> > porting a VB6 webclass app to VB.NET and therefore I am trying to make > it
>> > as
>> > efficent as possible via the new functionality of VB.NET.
>> >
>> > At present I have (in various places):
>> > variableX = variableX.Replace("a string", "another string")
>> >
>> > In some cases the above variableX will have 4+ replaces virutally
>> > one
>> > after
>> > the
>> > other with 1 or 2 of the replacement strings having length > 100.
>> >
>> > This seems like the perfect candidate for StringBuilder.Replace instead > of
>> > String.Replace
>> > what does anybody think?
>> >
>> > Regards,
>> > Pete
>> >
>> >
>>
>>
>
>



Nov 20 '05 #8

P: n/a
Peter,
Remember that the StringBuilder over allocates its buffer, a string only
ever holds how ever many characters are in it!

The StringBuilder.Capacity property is how many characters the buffer will
hold, while StringBuilder.Length is how many characters are in use. Normally
you should set StringBuilder.Capacity to a value larger then the expected
resultant string. Other wise as Ken stated the StringBuilder will need to
reallocate its buffer. When the StringBuilder reallocates its buffer, it
doubles it in size, which means after a couple reallocates it is probably
significantly larger then it needs to be, by default capacity starts at 16.
By setting the Capacity value when you start (in the constructor for
example) you save the reallocations of the StringBuilder's buffer. You can
use StringBuilder.MaxCapacity to limit to maximum capacity that a
StringBuilder can be expanded to.

For example, I am creating a new StringBuilder that is initialized to my
template "<head><body><tail>", however I am setting the capacity of that
StringBuilder to 1024, which is clearly larger then my three replacement
values. When I use sb.Replace, because the buffer capacity is larger then
the result, the buffer is not reallocated...

Dim sb As New StringBuilder("<head><body><tail>", 1024)
Dim head As New String("h"c, 200)
Dim body As New String("b"c, 200)
Dim tail As New String("t"c, 200)

sb.Replace("<head>", head)
sb.Replace("<body>", body)
sb.Replace("<tail>", tail)

Hope this helps
Jay

"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Hi,

Eh? I don't get what you are saying?

If I have a SBuilder with length 100 and I replace "<head>" (length 6) with a string
that is 200 in length then the Sbuilder has no choice but to resize surely; because
you are replacing 6 out of 100 with 200 hence the length after the replace
would be
294 which is 194 larger than before the operation??

Therefore since it is resizing it then you'd assume there is some overhead
to that.
So how does that overhead compare to doing a :
Str = Str.Replace("<head>", str2)

Regards,
Peter
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

The stringbuilder will only resize if the string is larger.

Ken
---------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Hi,

The link provided gives a lot of info but leaves out some important info hence the original question.

If I have a stringbuilder and lets say it has length = 100, I also have strHeaderStuff with length = 200.
For the sake of argument lets also say that .IndexOf("<head>") is 25 and
I
say:

MyStrBldr.Replace("<head>", strHeaderStuff)

The stringbuilder object is increasing it's size and inserting at a
position
it has to find first.
So I still need to be convinced that doing it this way will be faster than doing:

SimpleString = SimpleString.Replace("<head>", strHeaderStuff)

I don't wanna start a massive flaming debate about the rights and
wrongs of
anything but...
wouldn't it of made more sense for MS to implement the String type to do the
same as a
StringBuilder under the covers and hence not have StringBuilder?

i.e
Dim str As String
Str = "Hello"
Str &= " World"

Is roughly the same as saying:
Dim sbr As New StringBuilder
sbr.Append("Hello")
sbr.Append(" World")

So if the stringbuilder is so much more efficent why not simply

implement the String that way
in the first place?

Regards,
Peter

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> When you use variableX = variableX.Replace("a string", "another> string") with a string it will it will create a new string in memory and> destroy the old one. The stringbuilder will reuse the memory space
> therefore it is quicker.
>
>

http://msdn.microsoft.com/library/de...ilderclass.asp
>
> Ken
> ----------------------
> "Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
> news:eV**************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I know this has been asked before, but reading the threads it is still not
> > entirely clear.
> > Deciding which .Replace( ) to use when.
> >
> > Typically if I create a string in a loop I always use a StringBuilder. At
> > present I am
> > porting a VB6 webclass app to VB.NET and therefore I am trying to make it
> > as
> > efficent as possible via the new functionality of VB.NET.
> >
> > At present I have (in various places):
> > variableX = variableX.Replace("a string", "another string")
> >
> > In some cases the above variableX will have 4+ replaces virutally one> > after
> > the
> > other with 1 or 2 of the replacement strings having length > 100.
> >
> > This seems like the perfect candidate for StringBuilder.Replace instead of
> > String.Replace
> > what does anybody think?
> >
> > Regards,
> > Pete
> >
> >
>
>



Nov 20 '05 #9

P: n/a
Hi,

At last someone that has something worthwhile to say, thanks!

So basically you have to take an educated guess based on your situation and
set the capacity.
I will have to do that as a phase 2 optimisation on my porting from VB6
project as I haven't
been setting the capacity when I use one.

Regards,
Peter
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ue**************@TK2MSFTNGP10.phx.gbl...
Peter,
Remember that the StringBuilder over allocates its buffer, a string only
ever holds how ever many characters are in it!

The StringBuilder.Capacity property is how many characters the buffer will
hold, while StringBuilder.Length is how many characters are in use. Normally you should set StringBuilder.Capacity to a value larger then the expected
resultant string. Other wise as Ken stated the StringBuilder will need to
reallocate its buffer. When the StringBuilder reallocates its buffer, it
doubles it in size, which means after a couple reallocates it is probably
significantly larger then it needs to be, by default capacity starts at 16. By setting the Capacity value when you start (in the constructor for
example) you save the reallocations of the StringBuilder's buffer. You can use StringBuilder.MaxCapacity to limit to maximum capacity that a
StringBuilder can be expanded to.

For example, I am creating a new StringBuilder that is initialized to my
template "<head><body><tail>", however I am setting the capacity of that
StringBuilder to 1024, which is clearly larger then my three replacement
values. When I use sb.Replace, because the buffer capacity is larger then
the result, the buffer is not reallocated...

Dim sb As New StringBuilder("<head><body><tail>", 1024)
Dim head As New String("h"c, 200)
Dim body As New String("b"c, 200)
Dim tail As New String("t"c, 200)

sb.Replace("<head>", head)
sb.Replace("<body>", body)
sb.Replace("<tail>", tail)

Hope this helps
Jay

"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Hi,

Eh? I don't get what you are saying?

If I have a SBuilder with length 100 and I replace "<head>" (length 6) with
a string
that is 200 in length then the Sbuilder has no choice but to resize

surely;
because
you are replacing 6 out of 100 with 200 hence the length after the replace
would be
294 which is 194 larger than before the operation??

Therefore since it is resizing it then you'd assume there is some overhead to that.
So how does that overhead compare to doing a :
Str = Str.Replace("<head>", str2)

Regards,
Peter
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

The stringbuilder will only resize if the string is larger.

Ken
---------------------
"Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> The link provided gives a lot of info but leaves out some important info > hence the original question.
>
> If I have a stringbuilder and lets say it has length = 100, I also have > strHeaderStuff with length = 200.
> For the sake of argument lets also say that .IndexOf("<head>") is 25 and
I
> say:
>
> MyStrBldr.Replace("<head>", strHeaderStuff)
>
> The stringbuilder object is increasing it's size and inserting at a
> position
> it has to find first.
> So I still need to be convinced that doing it this way will be faster than
> doing:
>
> SimpleString = SimpleString.Replace("<head>", strHeaderStuff)
>
> I don't wanna start a massive flaming debate about the rights and wrongs > of
> anything but...
> wouldn't it of made more sense for MS to implement the String type
to do > the
> same as a
> StringBuilder under the covers and hence not have StringBuilder?
>
> i.e
> Dim str As String
> Str = "Hello"
> Str &= " World"
>
> Is roughly the same as saying:
> Dim sbr As New StringBuilder
> sbr.Append("Hello")
> sbr.Append(" World")
>
> So if the stringbuilder is so much more efficent why not simply

implement
> the String that way
> in the first place?
>
> Regards,
> Peter
>
> "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
> news:OA**************@TK2MSFTNGP12.phx.gbl...
>> Hi,
>>
>> When you use variableX = variableX.Replace("a string", "another >> string") with a string it will it will create a new string in
memory and
>> destroy the old one. The stringbuilder will reuse the memory space
>> therefore it is quicker.
>>
>>
>

http://msdn.microsoft.com/library/de...ilderclass.asp >>
>> Ken
>> ----------------------
>> "Peter Row" <pe*******@oxfordcc.co.uk> wrote in message
>> news:eV**************@TK2MSFTNGP09.phx.gbl...
>> > Hi,
>> >
>> > I know this has been asked before, but reading the threads it is

still
> not
>> > entirely clear.
>> > Deciding which .Replace( ) to use when.
>> >
>> > Typically if I create a string in a loop I always use a

StringBuilder.
> At
>> > present I am
>> > porting a VB6 webclass app to VB.NET and therefore I am trying to

make
> it
>> > as
>> > efficent as possible via the new functionality of VB.NET.
>> >
>> > At present I have (in various places):
>> > variableX = variableX.Replace("a string", "another string") >> >
>> > In some cases the above variableX will have 4+ replaces virutally

one >> > after
>> > the
>> > other with 1 or 2 of the replacement strings having length > 100.
>> >
>> > This seems like the perfect candidate for StringBuilder.Replace

instead
> of
>> > String.Replace
>> > what does anybody think?
>> >
>> > Regards,
>> > Pete
>> >
>> >
>>
>>
>
>



Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.