"Concatenation" is not defined on integer, isn't it? :-)
And don't concatenate repetitively even the string. This is inefficient, because strings are
immutable. On each concatenation, the brand new instance of the string is created, old data is copied, and so on.
You need to use either
string.Format
or mutable
System.Text.StringBuilder
.
With
Format
, you can work with any types, for example:
string result = string.Format("I'm using several integer values, this: {0}, this: {1}, this: {2} and that: {3}", opt, opt1, opt2, opt3);
In a cycle, you would need to use
StringBuilder
, but the data to be appended/inserted should be formatted to string using the universal method
object.ToString()
.
[EDIT]
For example:
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("some text");
sb.Append(someInteger.ToString());
sb.Append(someDateTime.ToString("yyyy/mm/dd hh:mm"));
sb.Append(anyObjectAtAll.ToString());
string result = sb.ToString();
—SA