Fields
Fields comprise the primary “data” portion of a class. They are synonymous with attributes, describing the features of a class. Their types could be primary types, user defined structures, or other classes. Although fields represent information about a class, can also be thought of as self-contained objects, each with their own behavior.
Field Initialization
Fields can be initialized during declaration or afterward, depending on style and/or the nature of requirements. There are pros and cons each way.
For example, a conservative approach may be to ensure that all fields have default values, which would lead to initialization of fields at declaration or soon thereafter. This is safe and perhaps it also helps plan design more thoroughly ...
Get C# 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.