.NET disassembled Part 1: Integers in .NET

Today I attended one of Juval Löwy’s sessions on our inhouse conference.

He argued that every object in .NET is a COM object behind the scenes, even Int32.
Fair enough, Int32 is a type and it does have a Guid.
The argument was an attempt to show that .NET is slow and that everything is pushed around as a COM object internally, even the integers…
(This was an up ramp for his “every object should be a WCF service”, to show that performance doesn’t matter, much..)

This is however completely wrong..
.NET have specific IL op codes in order to deal with primitives, and those opcodes will translate to pure machine code.

Here is a C# code snippet:

Here is the same code disassembled into x86

The value hex 7B (dec 123) is moved directly into the memory slot for the local variable.
No COM objects involved, no nothing, just normal machinecode, as long as you treat it as an int that is..
You can not make this faster or better even if you resort to pure ASM.


  1. Wow, that’s a really old myth… would have thought in the nine years since it came out that would have been thoroughly squashed…

  2. hm, first of all one should agree upon the topic… juval said about “every class as a service” not “objects as WCF service”. there is quite a distinction between the two. i do quite am skiptic about the fact of what he said the OOP was a total disaster. :) another is, somewhere, somehow, one should implement the interface part…so OO is out of the question?

  3. Could anyone help me out? Why does C# have a nop in it’s assembly? What good does it bring to the code other than doing nothing?

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s