Click here to Skip to main content
15,891,864 members
Home / Discussions / C#
   

C#

 
GeneralVirus removal tool (Team Project). Pin
MS-EULA8-Apr-10 1:31
MS-EULA8-Apr-10 1:31 
GeneralTo Up Pin
MS-EULA9-Apr-10 2:01
MS-EULA9-Apr-10 2:01 
Questionopen an exe file in panel Pin
MarziehA8-Apr-10 0:34
MarziehA8-Apr-10 0:34 
AnswerRe: open an exe file in panel Pin
Eddy Vluggen8-Apr-10 6:14
professionalEddy Vluggen8-Apr-10 6:14 
QuestionLimitations of windows forms Pin
QuinsUK8-Apr-10 0:17
QuinsUK8-Apr-10 0:17 
AnswerRe: Limitations of windows forms Pin
TheFoZ8-Apr-10 1:00
TheFoZ8-Apr-10 1:00 
AnswerRe: Limitations of windows forms Pin
kevinnicol8-Apr-10 4:39
kevinnicol8-Apr-10 4:39 
QuestionKeyDown event in console Pin
bolikej7-Apr-10 22:59
bolikej7-Apr-10 22:59 
I am creating a snake game on the console (c#)(it is a school assignment and it has to be on console) but I’m struggling with the change of direction and this is because I can’t figure out how to use an eventhandler with keydown properly in console.

I’ve put together some mock up code below which more or less explains what I try to accomplish

I have tried several things but it is tricky to do on the console.

Any hints, suggestions would be greatly appreciated.

void KeyDown(object sender, EventArgs e)
{
if(e.thepressedkey == Right.Arrow)
	method_a()
if(e.thepressedkey == Left.Arrow)
	method_b()
}

void a()
{
	while(something)
	{
		snake.moveright();
		thread.sleep(500);
	}
}

void b()
{
	while(something)
	{
		snake.moveleft ();
		thread.sleep(500);

	}
}

AnswerRe: KeyDown event in console Pin
Mustafa Ismail Mustafa7-Apr-10 23:54
Mustafa Ismail Mustafa7-Apr-10 23:54 
GeneralRe: KeyDown event in console Pin
bolikej8-Apr-10 2:06
bolikej8-Apr-10 2:06 
GeneralRe: KeyDown event in console Pin
Mustafa Ismail Mustafa8-Apr-10 2:59
Mustafa Ismail Mustafa8-Apr-10 2:59 
GeneralRe: KeyDown event in console Pin
bolikej8-Apr-10 10:03
bolikej8-Apr-10 10:03 
GeneralRe: KeyDown event in console Pin
Mustafa Ismail Mustafa8-Apr-10 10:17
Mustafa Ismail Mustafa8-Apr-10 10:17 
QuestionAn equivalent of -javaagent in C#? Or: ways to use a java framework in C# Pin
blackblizzard7-Apr-10 22:24
blackblizzard7-Apr-10 22:24 
Questionsetting focus on masked textbox control added in datagridview Pin
Nouman Bhatti7-Apr-10 20:57
Nouman Bhatti7-Apr-10 20:57 
AnswerRe: setting focus on masked textbox control added in datagridview Pin
yogesh_kumar_agarwal7-Apr-10 21:03
yogesh_kumar_agarwal7-Apr-10 21:03 
GeneralRe: setting focus on masked textbox control added in datagridview Pin
Nouman Bhatti7-Apr-10 21:09
Nouman Bhatti7-Apr-10 21:09 
GeneralRe: setting focus on masked textbox control added in datagridview Pin
yogesh_kumar_agarwal7-Apr-10 21:16
yogesh_kumar_agarwal7-Apr-10 21:16 
GeneralRe: setting focus on masked textbox control added in datagridview Pin
Nouman Bhatti7-Apr-10 21:22
Nouman Bhatti7-Apr-10 21:22 
GeneralRe: setting focus on masked textbox control added in datagridview Pin
yogesh_kumar_agarwal7-Apr-10 23:49
yogesh_kumar_agarwal7-Apr-10 23:49 
QuestionWhat OracleType to use for table of record output parameter Pin
whiteadi7-Apr-10 20:51
whiteadi7-Apr-10 20:51 
QuestionMessage Removed Pin
7-Apr-10 20:30
arun_pk7-Apr-10 20:30 
AnswerRe: xml reading Pin
SeMartens7-Apr-10 21:03
SeMartens7-Apr-10 21:03 
GeneralRe: xml reading Pin
arun_pk8-Apr-10 1:36
arun_pk8-Apr-10 1:36 
AnswerRe: xml reading Pin
Mirko19807-Apr-10 23:23
Mirko19807-Apr-10 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.