Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question