introductory-examples/references/reference-demo.cs - Demonstrations of references in C#. | Lecture 2 - slide 11 : 43 Program 1 |
using System; public class C { public double x, y; } public class ReferenceDemo { public static void Main(){ C cRef, anotherCRef; cRef = null; Console.WriteLine("Is cRef null: {0}", cRef == null); cRef = new C(); Console.WriteLine("Is cRef null: {0}", cRef == null); Console.WriteLine("x and y are ({0},{1})", cRef.x, cRef.y); anotherCRef = F(cRef); } public static C F(C p){ Console.WriteLine("x and y are ({0},{1})", p.x, p.y); return p; } }