using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int age = Convert.ToInt32(Console.ReadLine()); int broAge = Convert.ToInt32(Console .Readline()); Console.WriteLine("You are {0} years old", "your bro is {1}", age, broAge ); } } }

please tell me whats wrong in this code?


8/20/2016 1:06:13 AM

Alaxander sam

6 Answers

New Answer


The problem it's at --years old", "your bro is-- If you wish to concatanate this it's not the way. For you code to work you must write: Console.WriteLine("You are {0} years old, your bro is {1}", age, broAge);


You may use: Console.WriteLine("You are " + age + " years old, your bro is " + broAge ); instead so that you will not be confused on how to use { }


You can only use " " at once


If you want to add multiple strings in a Console.WriteLine(); You must seperate them with a +. Console.WriteLine("You are {0} years old," + "your bro is {1}", age, broAge );


Since Visual Studio 2015 we can now do it like: Console.WriteLine($"Your are {age} years old and your bro is {broAge} old"); This saves a lot of space when the strings get more complicated.


you make mistakes in spelling of "Readline" and "ReadLine"