在课堂上我有蛇:
public Snake()
{
snakeRec = new Rectangle[3];
if(Form1.diffeasy = true)
{
colorid = "Green";
}
else if (Form1.diffnormal = true)
{
colorid = "blue";
}
else if (Form1.diffhard = true)
{
colorid = "purple";
}
else if (Form1.diffextreme = true)
{
colorid = "red";
}
Sbrush = new SolidBrush(Color.FromName(colorid)
现在 diffextreme, diffeasy,... 在 Form1 中定义为
bool diffeasy = false;
bool diffnormal = false;
bool diffhard = false;
bool diffextreme = false;
当用户选择一个难度时,其中一个设置为 true。
我的问题是:如何在蛇类中正确访问这些布尔值?