- 1

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?

20th Aug 2016, 1:06 AM
Alaxander sam
Alaxander sam - avatar
7 Respostas
+ 1
You can only use " " at once
20th Aug 2016, 9:39 AM
Burakcan Duzcan
Burakcan Duzcan - avatar
+ 1
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 );
20th Aug 2016, 10:24 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
+ 1
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 { }
21st Aug 2016, 7:14 PM
Erwin Mesias
Erwin Mesias - avatar
+ 1
Since Visual Studio 2015 we can now do it like: Console.WriteLine(
quot;Your are {age} years old and your bro is {broAge} old"); This saves a lot of space when the strings get more complicated.
27th Aug 2016, 6:55 PM
Er ik
Er ik - avatar
+ 1
you make mistakes in spelling of "Readline" and "ReadLine"
17th Oct 2016, 7:46 AM
┹⎷┹⎷
┹⎷┹⎷ - avatar
0
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);
20th Aug 2016, 9:12 AM
Gighi
Gighi - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SearchApplication { class Program { static void Main(string[] args) { int[] LA = {1,3,5,7,8}; int item = 5, n = 5; int i = 0, j = 0; Console.WriteLine("The original array elements are :"); for(i = 0; i<n; i++) { Console.WriteLine("LA[{0}] = {1}", i, LA[i]); } while( j < n){ if( LA[j] == item ){ break; } j = j + 1; } Console.WriteLine("Found element {0} at position {1}", item, j+1); Console.ReadKey(); } } }
21st Mar 2021, 8:49 AM
Ù…Ű­Ù…ŰŻ Ű§Ù„Ù…ÙˆÙ„Ù‰
Ù…Ű­Ù…ŰŻ Ű§Ù„Ù…ÙˆÙ„Ù‰ - avatar