コンソールで押されたキーが等しい場合、つまり押されたキーが左矢印キーであった場合、コンソールの背景色をシアンに変更して、キーを比較したいと思います。
ただし、コンソールでキーを比較する方法がわからないため、Ifステートメントの設定方法がわかりません。
using System;
namespace ConsolePaint
{
class MainClass
{
public static void Main (string[] args)
{
ConsoleKeyInfo keypress;
keypress = Console.ReadKey(); // read keystrokes
if ( keypress.KeyChar == ConsoleKey.LeftArrow )
{
Console.BackgroundColor = "Cyan";
}
}
}
}