O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

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

2.3. Declaring Data Members

A data member represents state information associated with an instance of a class, such as the name of a file or the capacity of an ArrayList. A class data member can be of any type. How do we discover the data members that we need to associate with a class?

One category of data members is the set that users provide when they create a class instance. For example, for our WordCount class, we require users to provide the name of a text file and optionally to indicate whether they wish a program trace or performance timings. It is likely that we'll need to store these values in associated class data members.

A second category of data members is the set of objects that are used across multiple member functions. If an object ...

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