Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Errrhhh ..... CSharp or VB
Message
De
26/09/2011 02:28:08
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01524423
Message ID:
01524694
Vues:
60
>
>Another newbie question -- isn't StringBuilder a bazillion times faster than String?


The purpose of StringBuilder is to avoid (1) Creating a lot of objects - stored on the heap and (2) cleaning up the objects when they are no longer needed = freeing space + compacting part of the heap

But creating a stringbuilder is also an object. It keeps an array (which is also an object) to store the characters. So, that's also two objects
Depending on what you do, it may have to expand the array. The way .net works is to create another array and copy the contents

For a few operations on a string, it may be better not to use the stringbuilder.



It depends
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform