Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Addition - fun - not what I thought
Message
De
05/07/2009 14:35:38
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01410144
Message ID:
01410185
Vues:
35
>>
>>First (i += 2)  sets i = 3
>>Second (i += 2)  sets i = 5
>>
>>Then
>>j = 2 + 3 + 5
>>
>
>Yes, I figured that, but more logically it would be
>
>j = 2 + 5 + 5

No,

it adds 2, then uses that value

On a stack we would have
2
3    // 2 is added to i, value of i = 3 here
5   //  2 is added to i, value of i = 5 here
Then two additions which would leave 10 on the stack
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform