Partial Types

Although at this point we’re focusing on members that live in types such as structs and classes, this is a good time to introduce the concept of partial definitions. To set the scene, we have to discuss the physical structure of a development project in terms of files and the types they define.

It’s typical and considered good style to define types in a file that has the same name as the type itself. For example, a class Person would be defined in a file called Person.cs. Although this is not required by the compiler or the runtime (in contrast to, say, Java, where folders and files play a role in type lookup), it has various advantages when browsing code.

During prototyping or experimentation, though, it’s often handy to put multiple ...

Get C# 5.0 Unleashed 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.