Interview Question in LINQ


 

Interview Question :: Help building solution in cSharp

I have this code completed so far but i cannot get anything to pop up when i build solution... I will include the code and if anyone can help me to get output I would greatly appreciate it...

Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Snakin
{
public partial class Form1 : Form
{
//somewhat of a coordinate system for the game
bool[,] point = new bool[51, 51];
//sets the direction that the snake is supposed to move: 1:up, 2:down, 3:left, 4:right,
int direction = 4;
public Form1()
{
InitializeComponent();
//This sets the starting snake
point[0, 0] = true;
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
//according to the array point this displays the blocks of the snake and fruit
Graphics g = e.Graphics;
int x = 0; int y = 0;
while (y < 51)
{
bool skip = false;
if (point[x, y] == true)
{ g.FillRectangle(Brushes.GreenYellow, x * 10, y * 10, 10, 10); }
if (x >= 50) { x = 0; y++; skip = true; }
if (x < 50 && skip == false) { x++; }
}

}


private void Form1_KeyDown(object sender, KeyEventArgs e)
{
// Invalidate the Eater before moving it
string result = e.KeyData.ToString();
switch (result)
{
case "Left":
direction = 3; break;
case "Right":
direction = 4; break;
case "Up":
direction = 1; break;
case "Down":
direction = 2; break;
}
}

private void timer1_Tick_1(object sender, EventArgs e)
{
try
{
int x = 0; int y = 0;
while (y < 51)
{
bool skip = false;
if (direction == 4)
{ if (point[x, y] == true) { point[x, y] = false; point[x + 1, y] = true; break; } }
if (direction == 3)
{ if (point[x, y] == true) { point[x, y] = false; point[x - 1, y] = true; break; } }
if (direction == 2)
{ if (point[x, y] == true) { point[x, y] = false; point[x, y + 1] = true; break; } }
if (direction == 1)
{ if (point[x, y] == true) { point[x, y] = false; point[x, y - 1] = true; break; } }
if (x >= 50) { x = 0; y++; skip = true; }
if (x < 50 && skip == false) { x++; }
}
Invalidate();
}
catch
{
MessageBox.Show("Game Over");
}
}

}
}

Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Snakin
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDe...
Application.Run(new Form1());
}
}
}
by ksk