我在编写我的chip8 Emu 时遇到了另一个问题。除了那些需要输入或涉及图形的指令之外,我已经设法让所有指令都能正常工作。
我正在尝试编写一个单独的类来简单地确定按钮是否被按下。我已经为此工作了一段时间,我认为我一定遗漏了一些非常简单的东西,或者我在概念上不理解某些东西。这是我正在写的课程,评论中有确切的错误
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class userIn
{
bool pressed = false;
public userIn()
{
}
public bool checkPress() //Error 9 'WindowsFormsApplication1.userIn.checkPress()': not all code paths return a value C
{ //<---- it is teling me that a closing bracket is expected here?
private void key5_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keyb_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key0_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keya_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keye_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key9_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key8_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key7_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keyd_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keyf_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key6_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key4_Click(object sender, EventArgs e)
{
pressed = true;
}
private void keyc_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key3_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key2_Click(object sender, EventArgs e)
{
pressed = true;
}
private void key1_Click(object sender, EventArgs e)
{
pressed = true;
}
return pressed; //Error 6 Invalid token 'return' in class, struct, or interface member declaration
}
}
} // 错误 8 类型或命名空间定义,或预期文件结尾
最后一行不适合该框
有没有人有任何想法或建议?
一如既往地感谢任何帮助!