A compile time error is one which is detected before teh program starts running:
int i = 17;
if (i - 5)
{
}
will cause a compilation error, because "i - 5" is not a boolean vlaue - it is integer - and
if
conditions must be bool in C#
A run time error is one that is only detected when the program runs:
int i = 17;
int[] ar = new int[3];
ar[i] = 42;
will cause a run time error, because the value of i being used as an array index is outside the bounds of the array.
Run time errors can be trapped with a
try...catch
block, compile time errors cannot.