A
A
ANYJT2021-12-10 18:43:41
C++ / C#
ANYJT, 2021-12-10 18:43:41

c# error The name 'Console.ReadLine' does not exist in the current context?

It seems that I wrote the code, made a class, I write there Console.ReadLine(); , error The name 'Console.ReadLine' does not exist in the current context.
61b3759a42e10871303421.png

using System;

namespace ConsoleApp2
{
    class Program
    {


        static void Main(string[] args)
        {
            string name = "";
            string civilizationName = "";
            int people = 0;
            int army = 0;
            double economy = 1.00;
            double money = 5.00;


            Console.WriteLine("Hello , write your name.");
            name = Console.ReadLine();
            Console.WriteLine("Name: ", name);
            Console.WriteLine("Write name of your civilization");
            civilizationName = Console.ReadLine();
            Console.WriteLine("Civilization name", civilizationName);
            Console.WriteLine("Hello , you can start your civilization . Write '1' to INFO , write '2' to Start. (read info before start)");
            var choose = Int32.Parse(Console.ReadLine());
            if (choose == 1)
            {
                Console.WriteLine($"Info = Name = {name}, Civilization Name = {civilizationName},People in Kingdom = {people} , Army in Kingdom = {army},Economy = {economy}, Money = {money}");
            }
            if (choose == 2)
            {
                Console.WriteLine("Okay... Starting the game.");
            }
        }
        class SkipDay
        {
            Console.ReadLine();

        }
    }
   
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-12-10
@ANYJT

Because you are not doing this in a method, but for some reason in a class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question