Re: Application["TotalPlayings"]++ doesn't work

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Compiler Error Message: CS0201: Only assignment, call, increment,
decrement, and new object expressions can be used as a statement

And:
(int)Application["TotalPlayings"]++;
Makes no sense.

Application["TotalPlayings"] returns an object,
(int)Application["TotalPlayings"] unboxes that object and returns
an int as a *copy* of that value,
When you use the "++" operator, you will use that on that copy,
not on the original. So the original Application["TotalPlayings"] is not updated.
Plus you might have a precedence problem: what would be evaluated first: the (int) or the ++?


Hans Kesting


.



Relevant Pages

  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... The decrement happens BEFORE the assignment (simple operator ... or int. ... Question 14 does NOT depend on whether the English word "between" is ... In ordinary speech it is used both ways! ...
    (comp.programming)
  • Re: small C puzzles
    ... > minus sign 20 times. ... > int main ... Sure it was obvious that the looping you do was always will decrement ... how on earth will be the looping exit when all decrement ...
    (comp.lang.c)
  • Re: Curious compiler warning
    ... During this method, I decrement start ... public static int foo ... code in this class basically just does String functions to count the ...
    (comp.lang.java.programmer)
  • Curious compiler warning
    ... I'm getting an odd compiler warning that I don't really understand. ... I decrement start and finish ... public static int foo ... I modified the code as follows to get rid of the warnings but is it really ...
    (comp.lang.java.programmer)
  • Re: Curious compiler warning
    ... I decrement start and finish ... public static int foo ...
    (comp.lang.java.programmer)