AdvancedAlgorithms.WheresWaldorf.Main C# (CSharp) Method

Main() static private method

static private Main ( string args ) : void
args string
return void
        static void Main(string[] args)
        {
            int numberOfRuns = int.Parse(Console.ReadLine());

            for (int runNumber = 0; runNumber < numberOfRuns; runNumber++)
            {
                //get the space
                Console.ReadLine();
                int numLines = NOT_INITIALIZED;
                int lineLength = NOT_INITIALIZED;
                //read the grid dimensions
                string dimensionline = Console.ReadLine();

                foreach (var number in dimensionline.Split(' '))
                {
                    if (numLines == NOT_INITIALIZED)
                        numLines = int.Parse(number);
                    else
                        lineLength = int.Parse(number);
                }

                numLines += 2;
                lineLength += 2;

                char[][] grid = new char[numLines][];
                //got our grid size, read all the lines
                for (int lineNumber = 0; lineNumber < numLines; lineNumber++)
                {
                    grid[lineNumber] = new char[lineLength];

                    string lineString = string.Empty;
                    //if its not an edge, read the line
                    if (lineNumber != 0 && lineNumber != numLines - 1)
                        lineString = Console.ReadLine().ToLower();

                    //read in the line
                    for (int linePosition = 0; linePosition < lineLength; linePosition++)
                    {
                        //if its the edges, fill it with -'s
                        if (linePosition == 0 || lineNumber == 0 || lineNumber == numLines - 1 || linePosition == lineLength - 1)
                        {
                            grid[lineNumber][linePosition] = NULL_CHARACTER;
                        }
                        else
                        {

                            //otherwise, read a character
                            grid[lineNumber][linePosition] = lineString[linePosition - 1];
                        }
                    }
                }

                //grid is set, now do the searching.
                int numberOfSearches = int.Parse(Console.ReadLine());

                for (int searchNumber = 0; searchNumber < numberOfSearches; searchNumber++)
                {
                    string textToFind = Console.ReadLine().ToLower();

                    Console.WriteLine(FindTextInGrid(textToFind, grid));
                }
                if (runNumber != numberOfRuns - 1)
                    Console.WriteLine();
            }
        }