Stackoverflow doing boxing in C#

Why, if there is not significant overload of CIL’s stack for second example, does it crash “faster” than the first one? Note that the number of CIL instructions does not accurately represent the amount of work or memory that will be used. A single instruction can be very low impact, or very high impact, so … Read more

Why does my application spend 24% of its life doing a null check?

The tree is massive By far the most expensive thing a processor ever does is not executing instructions, it is accessing memory. The execution core of a modern CPU is many times faster than the memory bus. A problem related to distance, the further an electrical signal has to travel, the harder it gets to … Read more

Performance of static methods vs instance methods

In theory, a static method should perform slightly better than an instance method, all other things being equal, because of the extra hidden this parameter. In practice, this makes so little difference that it’ll be hidden in the noise of various compiler decisions. (Hence two people could “prove” one better than the other with disagreeing … Read more

Why does the C# compiler translate this != comparison as if it were a > comparison?

Short answer: There is no “compare-not-equal” instruction in IL, so the C# != operator has no exact correspondence and cannot be translated literally. There is however a “compare-equal” instruction (ceq, a direct correspondence to the == operator), so in the general case, x != y gets translated like its slightly longer equivalent (x == y) … Read more