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.6. Member Initialization

Each class data member is automatically initialized to the default value of its type. Numeric types, such as int and double, have a default value of 0. false is the default value of type bool. null serves as the default value of all reference types. This default initialization is carried out as part of the invocation of operator new.

If the default values are the appropriate initial member values, there is nothing additional for us to program—at least in terms of initialization. Otherwise, how we assign an alternative initial value depends on whether the class designer or class user designates what that value should be.

If the class designer is the one determining the alternative initial value, she can explicitly specify ...

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