none
I wneed help RRS feed

  • Question

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace someting2
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Varibles
                
                int num;
                int num2;
       
    
                //Commands
               
                Console.WriteLine("Type 2 Numbers");
    
                Console.Write("Number 1");
                Console.ReadLine(num);
    
                Console.Write("Number 2");
                Console.ReadLine(num2);
    
                if (num < num2)
                {
                    Console.WriteLine("u suck");
                }
                else
                 Console.WriteLine("U RULE!! YHE");
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
            }
        }
    }
    
    
    Severity Code Description Project File Line Suppression State
    Error CS0165 Use of unassigned local variable 'num' someting2 C:\Users\Liam\source\repos\someting2\someting2\Program.cs 24 Active
    Error CS1501 No overload for method 'ReadLine' takes 1 arguments someting2 C:\Users\Liam\source\repos\someting2\someting2\Program.cs 24 Active
    Error CS0165 Use of unassigned local variable 'num2' someting2 C:\Users\Liam\source\repos\someting2\someting2\Program.cs 27 Active
    Error CS1501 No overload for method 'ReadLine' takes 1 arguments someting2 C:\Users\Liam\source\repos\someting2\someting2\Program.cs 27 Active
    i want to make so u type 2 number in console and if num is lower then num 2 it will say u suck! plz help
    Wednesday, April 4, 2018 10:46 PM

All replies

  • Console.ReadLine does not take any arguments (nothing in the parentheses). It returns a string, which you must convert to an integer.

    Here is a simple fix.

             Console.Write("Number 1");
             string snum = Console.ReadLine();
             num = Convert.ToInt32(snum);
    
             Console.Write("Number 2");
             string snum2 = Console.ReadLine();
             num2 = Convert.ToInt32(snum2);

    A better way that is slightly more complicated would be to use TryParse (you can Google it if you're interested).

    Wednesday, April 4, 2018 11:41 PM