Chapter 7. Types

In C# all code belongs to a type. Normally we represent types as classes, but types can also be structures, enumerations, interfaces, etc. Because every code belongs in a type, a number of tasks relating to types are important to understand when writing applications. These tasks include being able to compare variables, being able to determine if an object is compatible with a certain type, and being able to convert from one type to another.

Beyond basic comparisons of variables to types and learning mechanisms for casting from one type to another, this chapter will also give you information for redefining cast operators. Cast operators let you define conversion rules for your classes.

Working with Types

As with every chapter, we ...

Get C# Web Development with ASP.NET: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.