Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Building String Expand / Collapse
Author
Message
Posted Saturday, June 13, 2009 7:41 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 8, 2014 10:53 PM
Points: 27, Visits: 202
I am building a string for a series of smaller strings. Which option is more efficient ?

Build the string using the & Operator
Build the string using the StringBuilder Object
Build the string using StringCreator Object
Build the string using the += Operator
Post #734503
Posted Saturday, June 13, 2009 9:43 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Wednesday, October 22, 2014 12:34 PM
Points: 31,181, Visits: 15,626
These look like C# of VB.NET questions, not SQL Server.

You can test these, write a loop to build 10,000 of each one, look at the cost/time of each.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #734517
Posted Saturday, June 13, 2009 10:00 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, May 9, 2013 8:07 AM
Points: 1,220, Visits: 2,614
Like Steve said, this may be better suited for the .Net forums, but just like everything. It depends. I rarely use StringBuilder when I code. I only use it when I have a lot of concatenation to do. I don't think there is any difference between + and & other than syntax.

This article has some good guidelines.

http://www.yoda.arachsys.com/csharp/stringbuilder.html


Ken Simmons
http://twitter.com/KenSimmons
Post #734523
Posted Saturday, June 13, 2009 10:40 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 8, 2014 10:53 PM
Points: 27, Visits: 202
Thanks for the article Ken it was really helpful.
Post #734533
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse