0

Can someone explain why this code doesn't work properly please?

// I am trying to output "My name is (x) and I am (y) years old. I can't see why the last line doesn't work. static void Main(string[] args) { string name; int age; Console.WriteLine("Please enter your first name"); name = Console.ReadLine(); Console.WriteLine(name); Console.WriteLine("Please enter your age"); age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(age); Console.WriteLine("My name is ", name + "and my age is", age); }

3rd Aug 2019, 6:26 PM
Emma
2 odpowiedzi
+ 5
replace the commas with “+” Console.WriteLine("My name is "+ name + " and my age is " + age);
3rd Aug 2019, 6:33 PM
Jake
Jake - avatar
+ 1
OMG Thanks Jake. It was driving me mad
3rd Aug 2019, 6:41 PM
Emma