#950 – C# Has a Unified Type System

C# has a unified type system, which means that all types inherit, directly or indirectly, from object (System.Object).  This includes both reference and value types.  It also includes all primitive types, like int and bool, as well as every type provided in the .NET Framework and every custom type that you define.

Because every type inherits from object, you can call any of the System.Object methods (e.g. Equals and ToString) on an instance of any type.

            Dog d = new Dog("Bob", 5);
            int i = 42;
            bool awake = true;

            Console.WriteLine(d.ToString());
            Console.WriteLine(i.ToString());
            Console.WriteLine(awake.ToString());

950-001