object. Equals Static Method With Watch Class C# with Example
using System; namespace CSharpClass { class Watch { public byte hour{set; get;} public byte minute{set; get;} public Watch() { hour = 12; minute = 0; } public Watch(byte h, byte m) { hour = h; minute = m; } public void DisplayTime() { Console.WriteLine(hour + ":" + minute); } } class UsingWatch{ static void Main(String[] arg){ Watch hmt = new Watch(10,12); Watch sonata = new Watch(10,10); Watch sameHMT = hmt; Console.Write("Both Watch have Same Time: {0}\n", object.Equals(hmt, sonata)); Console.Write("Both References Pointing Same Object: {0}\n", object.ReferenceEquals(hmt, sameHMT)); } } }