Object.ReferenceEquals Method : Object Instance : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Object Instance »

 

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();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Object Instance