The String Concatenation: Difference between revisions
From Catglobe Wiki
More actions
 jrfconvert import  | 
				No edit summary  | 
				||
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:  | [[Category:Operators]]  | ||
  | {{HelpFiles}}  | ||
===The String Concatenation===  | ===The String Concatenation===  | ||
| Line 7: | Line 7: | ||
For example, if we have an expression: “1” + 6, its value is a string: “16”.  | For example, if we have an expression: “1” + 6, its value is a string: “16”.  | ||
===Invariant strings===  | |||
Strings are invariant, meaning that an existing string cannot be changed.  | |||
Therefore when making a string concatenation, a new string must be allocated.  | |||
If this is done excessively, e.g. in a loop, this may result in severe performance degradation of the script and possible the whole server.  | |||
Use the [[StringBuilder_class|StringBuilder]] when it is necessary to do this kind of processing.  | |||
__NOTOC__  | __NOTOC__  | ||
<!-- imported from file: 258.htm-->  | <!-- imported from file: 258.htm-->  | ||
Latest revision as of 13:31, 10 February 2012
The String Concatenation
CGS uses operator ‘+’ for concatenating string expressions. When the operator ‘+’ is used between a string and a number expression, the number expression will be converted to a string and then concatenated to the string expression.
For example, if we have an expression: “1” + 6, its value is a string: “16”.
Invariant strings
Strings are invariant, meaning that an existing string cannot be changed. Therefore when making a string concatenation, a new string must be allocated.
If this is done excessively, e.g. in a loop, this may result in severe performance degradation of the script and possible the whole server.
Use the StringBuilder when it is necessary to do this kind of processing.