#187 – Everything Is an Object

In C#, every data item is an object, created on the stack or the heap.  Even built-in data types, like double or int represent classes (System.Double and System.Int32) and declaring an object to be of one of these types is equivalent to instantiating an object of the appropriate type.

            // Declare and instantiate an int
            int i = 12;

            // Equivalent to
            System.Int32 i2 = new System.Int32();
            i2 = 12;

Similarly, every function call involves calling a method declared in some type–either a static or an instance method.

Even constants represent instances of some object.