C#: how to construct strings
Posted
by Craig Johnston
on Stack Overflow
See other posts from Stack Overflow
or by Craig Johnston
Published on 2010-05-06T06:19:04Z
Indexed on
2010/05/06
6:38 UTC
Read the original article
Hit count: 197
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
© Stack Overflow or respective owner