using System;
public class ConsoleReadKey
{
public static void Main()
{
ConsoleKeyInfo cki;
int x = 40, y = 12; 1. 커서위치 초기값 지정
for ( ; ; )
{
Console.Clear();
Console.SetCursorPosition(x, y); 2.커서좌표 위치
Console.Write('#');
cki = Console.ReadKey(true); 3. cki에 키 값 저장
switch(cki.Key)
{
case ConsoleKey.LeftArrow:
x--; 왼쪽
break;
case ConsoleKey.RightArrow:
x++; 오른쪽
break;
case ConsoleKey.UpArrow:
y--; 위
break;
case ConsoleKey.DownArrow:
y++; 아래
break;
case ConsoleKey.Q:
return; 종료
}
}
}
}
'.Net Project > .Net C#' 카테고리의 다른 글
06장 변수 (0) | 2009.08.04 |
---|---|
05장 이스케이프 시퀀스 (0) | 2009.08.04 |
03장 자리표시자(=자리채움자) (0) | 2009.08.04 |
02장 HelloWord 출력 (0) | 2009.08.04 |
01장 C# 기본구조 (0) | 2009.08.04 |