Can i use a variable name in stand of placeholders | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Can i use a variable name in stand of placeholders

23rd Feb 2017, 1:10 PM
Lindokuhle
Lindokuhle - avatar
4 Réponses
+ 5
yes you can Console.WriteLine("i am " + age + "years old"); from c# 6.0 there is another way to achive the same: Console.WriteLine(
quot;i am {age} years old"); note $ at before the string!
25th Feb 2017, 9:06 PM
HAL8999++;
HAL8999++; - avatar
+ 2
Dear Lindokuhle What do you mean of this? Please , Put the code that you are thinking about. :) Sorry for this but my English is not very good. But anyway I'll try to help you.
24th Feb 2017, 7:33 PM
D3F4U1T
+ 2
int age = 12; System.Console.WriteLine("I am {0} years old", age); why can't I do this? int age =12; System.Console.WriteLine("i am " + age "years old");
24th Feb 2017, 9:47 PM
Lindokuhle
Lindokuhle - avatar
+ 2
Dear Lindokuhle You missed a Plus (+) after putting the variable ->>> age Correct form: int age = 12; System.Console.WriteLine("i am " + age + "years old"); Best regards :)
25th Feb 2017, 6:05 PM
D3F4U1T