O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required