static void Enqueue (string toInsert) { Node cur = head; if (cur == null) { head = new Node(toInsert); } else { while (cur.next != null) { // SLOW - NOT GOOD cur = cur.next; } cur.next = new Node(toInsert); } } - - - static void Enqueue (string toInsert) { if (head == null) { head = new Node(toInsert); tail = head; } else { tail.next = new Node(toInsert); tail = tail.next; } } - - - static string Dequeue () { if (head == null) return ""; string rv = head.data; head = head.next; return rv; } - - - static void Push (string toInsert) { Node temp = new Node(toInsert, head); head = temp; } - - - static string Pop () { if (head == null) return ""; string rv = head.data; head = head.next; return rv; } ----------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace _2313_keypress_example { public partial class Form1 : Form { private int _x; private int _y; private const int MapWidth = 100; private const int MapHeight = 50; public int X { get { return _x; } set { if ((value >= 0) && (value < MapWidth)) _x = value; } } public int Y { get { return _y; } set { if ((value >= 0) && (value < MapHeight)) _y = value; } } public Form1() { InitializeComponent(); X = 40; Y = 40; } private void Form1_KeyDown(object sender, KeyEventArgs e) { // MessageBox.Show(e.KeyCode.ToString()); switch (e.KeyCode) { case Keys.Up: Y--; break; case Keys.Down: Y++; break; case Keys.Left: X--; break; case Keys.Right: X++; break; } label1.Text = "x=" + X + " y=" + Y; } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { // MessageBox.Show(e.KeyChar.ToString()); } } }