O'Reilly logo

Pro C# 2010 and the .NET 4 Platform, Fifth Edition by Andrew Troelsen

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

8.10. Understanding Lazy Object Instantiation

NOTE

This section assumes you are comfortable with the topics of .NET generics and .NET delegates. If that's not the case, you may want to return to this section once you have completed Chapters 10 and 11.

When you are creating classes, you may occasionally need to account for a particular member variable in code, which may never actually be needed, in that the object user may not call the method (or property) that makes use of it. Fair enough. However, this can be very problematic if the member variable in question requires a large amount of memory to be instantiated.

For example, assume you are writing a class that encapsulates the operations of a digital music player. In addition to the expected ...

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