Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Optimized way to transfer from String to StringBuilder
Message
 
À
05/02/2014 16:56:35
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01593079
Message ID:
01593753
Vues:
49
If you're running in a loop the entire string routine should probably be going into StringBuilder(). String concatenation in .NET is expensive because every string - dynamic or static - requires an object reference. While they are short lived they use memory and use the heap and .NET has to keep track of it and clear out those references. So if you're doing under 10 concats total there's no need to use a StringBuilder. Anything more StringBuilder starts making sense in addition to often being an easier interface to output string data.

+++ Rick ---

>>If those are the only two strings you're dealing with in the block before the string is complete and then used, then you don't need a string builder. StringBuilder starts being more efficient around 6-8 concatenations but before that it's not going to matter much.
>>
>>Unless you're running this code in a loop - don't bother with a string builder.
>
>Yes, it is running in a loop. But, rarely does it relate to a big chunk of text being processed. So, I left it as is for now.
>
>Thanks for the additional information
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform