You can easily perform string contatenation like this:
string a = "hello";
string b = " world";
string c = a+b; // c contains hello world
Not a good idea ! Why ? because strings are immutable and everytime you concatenate the new copy of the string is made meaning a new object. So if you want to concatenate two strings use the StringBuilder class append method. StringBuilder has a link list data structure and no new objects are made when concatenation operation is performed.
No comments:
Post a Comment