我是一个初学者程序员,我是使用Visual Basic.net编写代码的,所以我想学习C#,可以帮助我解决此代码
您好,此代码有什么错误?
enum Day
{
Saturday, Sunday, Monday, Tuesday, Wednesday,Thursday, Friday
}
public static void ShowDay(Day CurrentDay) // Error
{
if (CurrentDay == Day.Friday)
Console.WriteLine("A vacation");
}
static void Main(string[] args)
{
Day X;
X = Day.Friday;
ShowDay(X);
ShowDay(Day.Friday);
}
最佳答案
您应该将您的enum
公开。
public enum Day
{
Saturday, Sunday, Monday, Tuesday, Wednesday,Thursday, Friday
}
UPD:或从
public
方法中删除ShowDay
。关于c# - 具有函数错误的枚举,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36621354/