我收到 2 个错误,CS8803 和 C20266
I am getting 2 errors, CS8803, and C20266
在编写一个控制台应用程序来计算周长时,当我编译我的代码时,我遇到了两个控制台错误(见上图)这是我的代码
Console.Title = "Constant";
enum Days { Sat, Sun, Mon, Tue, Wed, Thu , Fri};
const double pi = 4159265358979;
var daystype = typeof(DayOfWeek);
Console.WriteLine("Pi Type" + pi.GetType());
Console.WriteLine("Circumfrence" + (pi * 3));
您不能将枚举放在局部函数中。您的应用程序结构应该是
public class Program
{
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };
static void Main()
{
Console.Title = "Constant";
const double pi = 4159265358979;
var daystype = typeof(DayOfWeek);
Console.WriteLine("Pi Type" + pi.GetType());
Console.WriteLine("Circumfrence" + (pi * 3));
}
}
在编写一个控制台应用程序来计算周长时,当我编译我的代码时,我遇到了两个控制台错误(见上图)这是我的代码
Console.Title = "Constant";
enum Days { Sat, Sun, Mon, Tue, Wed, Thu , Fri};
const double pi = 4159265358979;
var daystype = typeof(DayOfWeek);
Console.WriteLine("Pi Type" + pi.GetType());
Console.WriteLine("Circumfrence" + (pi * 3));
您不能将枚举放在局部函数中。您的应用程序结构应该是
public class Program
{
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };
static void Main()
{
Console.Title = "Constant";
const double pi = 4159265358979;
var daystype = typeof(DayOfWeek);
Console.WriteLine("Pi Type" + pi.GetType());
Console.WriteLine("Circumfrence" + (pi * 3));
}
}