title: Convert a 2D array of ints to a greyscale image
body: <p>I have a 2D array of ints ranging from 0 to 255, each representing a shade of grey. I need to turn it into a greyscale image. The width and height of the image are the number of columns and rows of the array, respectivly.</p>
  
  <p>I am using Microsoft Visual C# 2010 Express with the latest (I think) .NET framework as of Feb, 2013.</p>
  
  <p>Many other people have had this problem but none of the solutions posted have worked for me; they all seem to call methods that don't exist in my code. I think I might missing a using statement or something.</p>
  
  <p>By the way I am very new to programming, so please explain everything as mush as possible.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: Okay, this is what I have:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              int width;
              int height;
              int[,] pixels;
              Random randomizer = new Random();
  
              Start:
              Console.WriteLine("Width of image?");
              string inputWidth = Console.ReadLine();
              Console.WriteLine("Height of image?");
              string inputHeight = Console.ReadLine();
  
              try
              {
                  width = Convert.ToInt32(inputWidth);
                  height = Convert.ToInt32(inputHeight);
              }
              catch (FormatException e)
              {
                  Console.WriteLine("Not a number. Try again.");
                  goto Start;
              }
              catch (OverflowException e)
              {
                  Console.WriteLine("Number is too big. Try again.");
                  goto Start;
              }
  
              pixels = new int[width, height];
  
              for (int i = 0; i &lt; width; ++i)
                  for (int j = 0; j &lt; height; ++j)
                  pixels[i, j] = randomizer.Next(256);
  
  
  
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>So here's some pseudo code of what I'm trying to do:</p>
  
  <pre><code>Initialize some variables
  
  Prompt user for preferred width and height of the resulting image.
  
  Convert input into Int.
  
  Set up the array to be the right size.
  
  Temporary loop to fill the array with random values. (this will be replaced with a series of equations when I can figure out how to write to a PNG or BMP.
  
  //This is where I would then convert the array into an image file.
  
  Wait for further input.
  </code></pre>
  
  <p>The other solutions that seemed to have helped other people use a class or object called bitmap, but I don't seem to have that class, nor do I know what library it is in. </p>