.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> Performace >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets


Posted By:Majith       Posted Date: September 06, 2010    Points: 10    Category: Performace    URL: http://www.dotnetspark.com  

Use String.Concat instead of '+' operator when you combine 2 string. this will better performance

In c# Applications in various scenario's programmer's using '+' operator for concatinating strings. its not best practice in the programming. Avoid using '+' operator instead of that always use string.concat() method. If its large string use string builder.

Sample Code :

 DataRow [] dr = dt.select("EmployeeId=" ' " + txtEmployeeId.Text + " ' ");


Replacement Code :


 DataRow [] dr = dt.select(string.concat("EmployeeId=" , txtEmployeeId.Text ));


Thanks ,

Happy Coding!


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend