Types and Interfaces

So far, the discussion of type has been largely structural, focusing on how a CLR type is held together. Issues of type semantics have largely been ignored. It is now time to look at how types convey semantics, starting with type categorization.

It is often desirable to partition types into categories based on common assumptions made by two or more types. Such categorization can serve as additional documentation for a type because only the types that explicitly declare affiliation with the category are known to share the assumptions implicit in that category. In the CLR, these categories of types are referred to as interfaces. Interfaces are type categories that are integrated into the type system. Because categories represented ...

Get Essential .NET, Volume 1: The Common Language Runtime 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.