+ 2
Can i use a variable name in stand of placeholders
4 Answers
+ 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!
+ 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.
+ 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");
+ 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 :)