The constructor for a reference type allocates memory in the heap and then supplies a reference to this. C# hides the underlying details and prevents the possibility of C/C++ null pointer problems.
However, unlike a value type, a reference type can be null.
But the compiler will usually stop you doing silly things. Objects in C# are generally easier to work with than in C++.
using System;This compiles and runs, up to the t.a = 5; assignment where it falls over as t is null. The = null makes the compiler happy that t has a value, even if at runtime it's not valid. Try removing the = null and the compiler will flag the error.
namespace ex1
{
class test
{
public int a = 9;
}
class ex1
{
static void Main(string[] args)
{
test t=null;
t.a = 5;
Console.ReadKey() ;
}
}
}
On the next page : Reference versus Value Types- Which to use?

