C#: how to construct strings
- by Craig Johnston
Which of these will achieve the correct result:
(1)
int X = 23;
string str = "HELLO" + X.ToString() + "WORLD";
(2)
int X = 23;
string str = "HELLO" + X + "WORLD";
(3)
int X = 23;
string str = "HELLO" + (string)X + "WORLD";
EDIT: The 'correct' result is to output: HELLO23WORLD