سؤال

Im trying to find the += in reflector in order to see how they implemented :

a=+1 vs a=a+1

but I cant find it.

any help ?

هل كانت مفيدة؟

المحلول

There is no implemetation for the += operator anywhere, it's a pseudo operator that is handled by the compiler. The C# compiler expands a += 1 into a = a + 1.

The JIT compiler then creates the most efficient code to do the a = a + 1. If it's a simple variable it will just be an instruction that increases the value.

نصائح أخرى

If you mean the += for int and the other built-in numerical types: there won't be a library function to look at. The compiler can translate them directly into IL instructions.

You could try the DateTime struct, and maybe Decimal as well.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top