O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

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

Behind the Scenes of Constructors

To satisfy our technical curiosity, we would like to know how constructors are called when writing code as shown earlier. As you already know, constructors are special methods that cannot be called directly. Their special treatment reaches beyond the managed code language compilers, though. The runtime also needs to treat them specially because they are tightly coupled with memory-allocation mechanisms and such.

Let’s illustrate matters by using the ILDASM for the TimeSpan constructor call, as shown in Figure 6.13.

Image

FIGURE 6.13 A constructor call for a value type unraveled.

In fact, a few different cases for constructor ...

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