Chapter 20. C# properties

C# properties are convenient alternatives to accessor (getter) and mutator (setter) methods in a class. It is something new and extremely useful. Do not confuse the term 'properties' in C# with the term 'properties' commonly used in OO nomenclature. Here, a property does not refer to a characteristic of a class, [1] although a C# property is still a class member.

[1] In OO literature, you will often see statements like 'a class contains properties, also known as attributes, which represent characteristics of a class'. properties and attributes in C# have different meanings. You use the term 'fields' or 'field variables' to represent the characteristics of a class.

What are called instance or static variables in Java, ...

Get From Java to C#: A Developer's Guide 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.