Keywords:

Keywords are directives built into the programming language which have special meaning to the compiler Using: imports source code that someone else made which we want to access

Hierarchy of Code:

Namespace, class and method (in this case, 'Main') group code together in a hierarchy of code blocks. The 'Program' class below is said to be a member of the 'HelloWorld' namespace. The 'Main' method is a member of the 'Program' class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld {  // The highest level grouping of code. Larger programs may organise their code in more namespaces with more classes and methods in them
    class Program {
        static void Main(string[] args) {  // This particular setup for a method indicates that this is the starting point for the program
            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
    }
}

Variables:

Loops:

Arrays:

Jagged array: when the smaller arrays have different lengths

int[][] matrix; // Declaring the larger array
matrix = new int[4][]; // Setting the amount of smaller arrays as 4, leaving the length of these smaller arrays undetermined
matrix[0] = new int[3];  // Setting the first small array to have a maximum index of 3
matrix[1] = new int[5];
matrix[2] = new int[9];
matrix[3] = new int[2];
matrix[2][1] = 7; // Assigning the second entry of the third array the value of 7
// To print out the jagged array:
for (int row = 0; row < matrix.Length; row++)
         {
             for (int col = 0; col < matrix[row].Length; col++)
             {
                 Console.Write(matrix[row][col]); 
             }
             Console.WriteLine();
         }

Rectangular Array: when the smaller arrays have the same lengths

int[,] matrix; // Uses [,] instead of [][] like in jagged arrays
matrix = new int[4, 4]; // The second argument is given. This makes matrix a multi-dimensional array with 4 arrays, each with a max range of 4 elements (0-3 index)
matrix[2, 1] = 7;
// To print the rectangular array:
for (int row = 0; row < matrix.GetLength(0); row++)  // Uses .GetLength(0) instead of .Length (0 gets the first dimension's length)
            {
                for (int col = 0; col < matrix.GetLength(1); col++) // Uses .GetLength(1) to get the second dimension's length
                {
                    Console.Write(matrix[row, col]);
                }
                Console.WriteLine();
            }