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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC 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)
  • Application["TotalPlayings"]++ doesnt work
    ... Compiler Error Message: CS0201: Only assignment, call, increment, ... decrement, and new object expressions can be used as a statement ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: C API: how to replace python number object in place?
    ... If x is a C variable of type PyObject*, and I happen to know already that ... could change it to the new value via an increment or decrement, ... C int and work with it, otherwise you have to use the APIs which create new ...
    (comp.lang.python)
  • c# conditional operator error
    ... Only assignment, call, increment, decrement, and new object expressions can be used as a statement ...
    (microsoft.public.dotnet.languages.csharp)