Data Members

The following sections look closer at the data members. Previous chapters have already covered instance variables, so the bulk of this part is about static variables and their use.

Instance Variables

When an object is created, its instance variables are filled with values specific to that object, and their values stay specific to this object throughout its lifetime. This mechanism is familiar territory, but worth recapturing to contrast it with static variables discussed in the next section.

Recall our BankSimulation.cs program in Chapter 10, “Arrays Part I: Array Essentials.” It consisted of a Bank object referencing a number of Account objects through an array called accounts. The Account class defined, among others, an instance ...

Get C# Primer Plus now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.