Properties

Although C# borrows many of its features from C++, there are some language features that are unique to C#. Properties are one such language feature. A property is a member that provides access to an attribute of an object or a class. Examples of properties can be the length of a string or size of font. Properties are an extension of fields. Both fields and properties are named elements with associated types. However, unlike fields, properties are not used to denote storage locations. Properties have accessors, which are used to specify the statements to execute in order to read or write their values. Properties thus provide a mechanism for associating actions with the reading and writing of private fields of an object. They are used ...

Get Special Edition Using C# 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.