Re: String Concatenation in VB.NET

From: Michael Pearson (michaelp_extrajunktoremove_at_televox.com)
Date: 06/29/04


Date: Tue, 29 Jun 2004 18:04:41 -0500

I second what Alex Says.
If I've got to concatinate two small strings, I usually just use &.
If I'm building a large string in a loop, System.Text.StringBuilder (I think
that's the right namespace) is the way to go by FAR.

Michael
"AlexS" <salexru2000NO@SPAMsympaticoPLEASE.ca> wrote in message
news:O4OCBjiXEHA.3988@tk2msftngp13.phx.gbl...
> Hi, YGeek
>
> Both are same in terms of memory and processor use. And both are
> sub-efficient. It is not recommended to use concatenation in loops and
> frequently.
> The fastest and most efficient way to combine strings is with
StringBuilder.
>
> HTH
> Alex
>
> "YGeek" <YGeek@discussions.microsoft.com> wrote in message
> news:0CDC04AB-AC06-4D24-B04D-E42EE5384C02@microsoft.com...
> > Is there a performance issue with using & to do string concatenation
> versus using the String.Concat method? What is the best practice for
doing
> string concatenation in VB.NET?
>
>



Relevant Pages

  • Re: C# coding guidelines: use "this." or not when referring to member fields/properties within the
    ... Alphabetic for strings isn't quite so ... One example of where people go wrong is when they want to optimise loop ... implementation so that each iteration takes 10% less time will only ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Error handling in a Do Loop
    ... I made the changes you suggested to my strings - blanking them correctly now. ... have any further suggestion or pointers, ... > When loop is able to ping a computer and able to pull the information, ... when the loop does not ping a computer/unable to ...
    (microsoft.public.windows.server.scripting)
  • Re: Stupid Newbie Needs Help
    ... Without the loop the program works fine with the ... with 0-terminated strings, that way you can take advantage of C's ... hold up to 10 tokens, where each token may be up to 80 characters ... should give a clue of how the variable/constant/function/macro is ...
    (comp.lang.c)
  • Re: timeit module: am I missing something obvious?
    ... Why am I passing strings around when functions are ... best of 3 trials: 0.792 usec per loop ... quickly choosing number of iterations. ... - The result from the final pass through the convergence loop ...
    (comp.lang.python)
  • Re: string concatenation optimizations [from python-dev Summary]
    ... Essentially what I have in mind is a type that's a list of byte ... The value is defined as the concatenation of these arrays. ... > way to concatenate a bunch of strings. ...
    (comp.lang.python)

Loading