Lequel de ces atteindront le résultat correct:C#: comment construire des chaînes
(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: Le résultat 'correct' est pour str
d'évaluer à: HELLO23WORLD
Ils font tous la même chose. –
Je dois le dire, Quel est le résultat correct? – LizB
Eh bien, à part le fait qu'il n'y a pas de 'toString()' en C#, c'est 'ToString()'. –