1)
StringBuilder sb = new StringBuilder("example");
sb.Append("example");
sb.Append("example");
sb.Append("example");
sb.Append("example");
sb.Append("example");
sb.Append("example");

String myString = sb.ToString()

2) string myString = "example" + "example" + "example" + "example" +
"example" + "example";

3)string myString = JoinArgs("example", "example", "example", "example",
"example", "example" );

which one is better.....I go for the first


On Thu, Feb 5, 2009 at 1:12 AM, jay <[email protected]> wrote:

>
> I wrote the function to be a replacement for doing something like
> this:
>
> string myString = "example" + "example" + "example" + "example" +
> "example" + "example";
>
> So instead you do this:
>
> string myString = JoinArgs("example", "example", "example", "example",
> "example", "example" );
>
>
> ..which I assume is faster since strings are immutable.
>
>
> On Jan 30, 1:08 am, Cerebrus <[email protected]> wrote:
> > Strings are immutable, the StringBuilder is mutable. The latter does
> > not use Strings internally.
> >
> > On Jan 30, 12:35 am, jay <[email protected]> wrote:
> >
> >
> >
> > > Does StringBuilder already do something like this? Or is what I have
> > > here good?
> >
> > > protected string JoinArgs( params string[] args )
> > > {
> > >         return String.Join( "", args );
> >
> > > }- Hide quoted text -
> >
> > > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
>

Reply via email to