Class Fields

The fields of a class constitute its data, what the compiler will allocate in memory when an object of this class is instantiated. The fields are fundamental to the class: Defining the correct fields is crucial. This is normally done as part of the design stage of the software development life cycle (SDLC).

Class fields can have access modifiers similar to the ones you encountered for the structure fields:

  • Public means that the field is accessible by anyone in this project and in other projects that use the class. Anyone can get the value of the field and set it back (if it is not a constant field).

  • Private means that the field is not visible to anyone but the object itself. You will see in the next chapter why this is useful.

  • Protected ...

Get Visual Basic® .NET by Example 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.