Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Addition - fun - not what I thought
Message
De
06/07/2009 04:54:09
 
 
À
06/07/2009 04:27:45
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:
01410224
Vues:
36
>>I think the documentation states that in these cases i is only evaluated once for the line. Given that the results will be as found.
>>e.g i += ++i; // 3 not 4
>>Best,
>>Viv
>
>
>Viv,
>
>Guess I was looking for side effects
>
>If I understand the definition of 'evaluated', then it will be evaluated twice in the example above since it's referenced twice on the right hand side
>i += ++i becomes i = i + ++i

No. Evaluated once per line not once per reference.
Given, say i=3 then
i += ++i;
would be equivalent to:
3 += ++3;
(I know you can't use the operators in this way - but you see what I mean)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform