System. Object Class Methods Using C# with Example
using System; namespace CSharpInheritance { class MyData { private double D1; private double D2; private double D3; public MyData(){} public MyData(double d1, double d2, double d3) { D1 = d1; D2 = d2; D3 = d3; } public double Sum() { return D1 + D2 + D3; } } class Program { static void Main(string[] args) { MyData p1 = new MyData(); Console.WriteLine("ToString: {0}", p1.ToString()); Console.WriteLine("Hash code: {0}", p1.GetHashCode()); Console.WriteLine("Type: {0}", p1.GetType()); MyData p2 = p1; object o = p2; // Are the references pointing to the same object in memory? if (o.Equals(p1) && p2.Equals(o)) { Console.WriteLine("Same instance!"); } Console.ReadLine(); } } }