- 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
8 odpowiedzi
+ 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
0
programs #Program 1 Variables using System.Linq; using System.Text; using System.Threading.Tasks; namespace EAU_ConsoleApplication { class Program { static void Main(string[] args) { int a = 10; string name = "Hassan "; int age = 30; Console.WriteLine(name); Console.WriteLine(age); } } } #Program 2 If Statement using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ifstatement { class Program { static void Main(string[] args) { Console.WriteLine("Please Enter a Number "); int num = int.Parse(Console.ReadLine()); if(num % 2 == 0) { Console.WriteLine("It is an Even Number"); } } } } #Program 3 If-Else Statement using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ifelsestatement { class Program { static void Main(string[] args) { Console.WriteLine("Please Enter a Number "); int num = int.Parse(Console.ReadLine()); if(num % 2 == 0) { Console.WriteLine("It is an Even Number"); } else { Console.WriteLine("It is an Odd Number"); } } } } #Program 4 Switch statement three using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace switchcase { internal class Program { static void Main(string[] args) { int day = 4; switch (day) { case 1: Console.WriteLine("Monday"); brea
5th May 2025, 1:31 PM
Cadnaan Yaasiin3
Cadnaan Yaasiin3 - avatar