A
A
ANYJT2021-11-25 09:42:59
C++ / C#
ANYJT, 2021-11-25 09:42:59

Compiler error CS1022,CS0841,CS118?

I have an error in my code
. A type or namespace definition is required, or an end-of-file sign.
It is not possible to use the local variable "Info" before declaring it.
"Info" is a variable, but is used as a type.
Cannot use local variable 'Info' before declaring it

using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {



            Console.WriteLine("Hello , write your name.");
            var name = Console.ReadLine();
            Console.WriteLine($"Name: {name} ");
            Console.WriteLine("Write name of your civilization");
            var civilzationName = Console.ReadLine();
            Console.WriteLine($"Civilization name - {civilzationName} ");
            Info = new Info
            {
                Name = name,
                CivilizationName = civilzationName
            };
            Console.WriteLine(Info);
        

            record Info;
        }
            
    public string Name { get; init; } = "";
        public string CivilizationName { get; init; } = "";
        public int People { get; init; }
        public int Army { get; init; }
        public double Economy { get; init; } = 1.00;
        public double Money { get; init; } = 5.00;
             }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-11-25
@ANYJT

Even from here you can see the curvature of the code formatting and the extra bracket at the end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question