private static void referenceTypeExample() { BigExample ex = new BigExample { ID = 123, Name = "TestName" }; BigExample ex2 = ex;//ex2 is simply as alias to ex..... ex2.Name = "Changed Name"; Console.WriteLine("{0} and {1}", ex, ex2); }
private static void referenceTypeArray() { BigExample[] elements = new BigExample[10];//Gets an Array of null objects. When u access the null object it throws NullReferenceException... for (int i = 0; i < elements.Length; i++) { elements[i] = new BigExample();//Instantiating all the objects of the Array... } foreach (var item in elements) { Console.WriteLine(item.Name); } //Throws a NullReferenceException... }