Pergunta

My code :

decimal fAnzahlAktuell = 12;
decimal fMenge = 2;
decimal fAnzahlReserviertPickpos = 0;

decimal a = ((decimal)(fAnzahlAktuell - fAnzahlReserviertPickpos)) > fMenge ? fMenge : (decimal)(fAnzahlAktuell - fAnzahlReserviertPickpos);
decimal b = (decimal)((fAnzahlAktuell - fAnzahlReserviertPickpos) > fMenge ? fMenge : (decimal)(fAnzahlAktuell - fAnzahlReserviertPickpos));

When i compile using x86 -> a and b both = 2

When i compile using anycpu -> a = 2 and b = 0

Can anybody explain why?!

EDIT : I am using VS2010 , .NET 4.0 on Windows 7 x64

enter image description here

Outras dicas

It's a quirk of the debugger.

The mis-reported value that you are observing can only be seen in the debugger. If you output the values, for instance to the console, then you will see that they are both 2 for all configurations.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top