Properties

With knowledge of the cornerstones of a type’s operations and state under our belts, we can proceed with our exploration of other members available on classes and structs. Properties are a mix between state and operations. On the one hand, they’re like fields providing get and set access to a piece of state; on the other hand, they’re like methods because those get and set operations can contain code. For those reasons, properties are sometimes said to be smart fields.

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.