c# - Order of evaluation, instance and method parameters -


suppose write following code:

int x = 42;  if (x.equals(x = foo()))     console.writeline("ok"); 

where foo method returning integer. guaranteed method invocation target (the first x) evaluated before replaced return value of foo()? in other words, code guaranteed print ok if , if return value of foo() equal 42?

i've seen other questions deal order of parameter evaluations, don't talk when instance (first x) gets evaluated during runtime non-static methods -- clarify me?

this problem called sequence points. represented happens when put increment operator inside expression.

in case of c# strictly defined expression , method parameters evaluated left right, inside out , assignment (and side effects in general) visible rest of expression.

you can read more here.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -