枚举类型这样定义大家看看可以不
private Direction _direction;//移动方向
public enum Direction//移动方向
{
Left,
Right,
Up,
Down
}
public Direction Direction
{
get { return _direction; }
set { _direction = value; }
}
提示是有歧义,我加上了类名
private Palette p;
if ((e.KeyCode == Keys.W) || (e.KeyCode == Keys.Up) && (p.Direction != Snake.Palette.Direction.Down))
{
p.Direction = Snake.Palette.Direction.Up;
这个句子看看怎么改才能用,原句是
if ((e.KeyCode == Keys.W) || (e.KeyCode == Keys.Up) && (p.Direction != Direction.Down))
{
p.Direction = Direction.Up;
------解决方案--------------------public Direction MyDirection
{
get { return _direction; }
set { _direction = value; }
}
------解决方案--------------------public enum Direction
public Direction Direction
这样子编译应该都通不过吧
------解决方案--------------------习惯不好造成问题,枚举和属性类型都是Direction了
enum可以改为EnumDirection
属性可以改为AttrDirection
更清晰