Why is decimal
not a primitive type?
Console.WriteLine(typeof(decimal).IsPrimitive);
outputs false
.
It is
Consider the below example ,
int i = 5;
float f = 1.3f;
decimal d = 10;
If you put a debugger and verify the native instruction set,it would be
As you can see int,float all being a primitive type takes single instruction to perform the assignemnt operation whereas decimal,string being non primitive types takes more than one native instruction to perform this operation.