Object.ReferenceEquals Method
using System; public class Starter { public static void Main() { Employee obj1 = new Employee(5678); Employee obj2 = (Employee)obj1.Clone(); if (Employee.ReferenceEquals(obj1, obj2)) { Console.WriteLine("objects identical"); } else { Console.WriteLine("objects not identical"); } } } class Employee : ICloneable { public Employee(int id) { if ((id < 1000) || (id > 9999)) { throw new Exception( "Invalid Employee ID"); } } public object Clone() { return MemberwiseClone(); } }
1. | Calling an Instance Method on an Object | ||
2. | Calling a Class Method on a Class | ||
3. | Catch NullReferenceException Exception | ||
4. | Object assignment | ||
5. | Point object | ||
6. | Pass by ref for object parameters |