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

Often the internal representation of a class is modified after its initial release to users. For example, in this first version of WordCount, m_trace is declared as a bool data member; that is, it is able to be set either to true or to false. For large text files, however, users have found the generated trace text overwhelming—at least when generated to the console. They have requested that we allow them to specify whether to direct the trace to the console or to a file. Supporting this flexibility requires a change to the type representation of m_trace. It must now be able to represent three states: traceOff, toConsole, and toFile.

If m_trace is declared as public, users are free to access it directly within their code. The result ...

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