none
Error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement.

    Question

  • Hi.

    I have the following code:

    private Dictionary<stringWFActivityDetails> ActivityDetails
            {
                get 
                { 
                    return this.initActivityData["ActivityDetails"as (Dictionary<stringWFActivityDetails>);
                }
            }

    which is showing the error:

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

    before compile. 

    this.initActivityData is a Hashtable variable.

    How do I fix this error?

    Wednesday, May 30, 2012 12:03 PM

Answers

  • Get rid of the parens around the return type. Since there are parens, C# is trying to execute that statement first, but is throwing an exception, as what's in the parens is not an " assignment, call, increment, decrement, [or]new object expression".

    Mike G.

    • Marked as answer by motionpotion Wednesday, May 30, 2012 12:48 PM
    Wednesday, May 30, 2012 12:10 PM