Home   Cover Cover Cover Cover
 

Type system

Question: What do we mean when we say C# has a uniform type system? What are the benefits of a uniform type system?

Answer: A uniform type system means that all types are derived from a common base type and are therefore compatible with this type. In C# this base type is object (System.Object). Reference types are directly compatible with object, value types are made compatible by boxing their values.

The benefit of a uniform type system is that variables of type object may reference values of any other type. They can not only contain values of class types but also int or char values (with boxing). This makes it possible to implement "generic" data structures which can be used with arbitrary element types.