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