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:
Related in same category :
-
-
-
-
-
-
|