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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.