Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The operand of an increment or decrement operator must be a variable, property or indexer.
This error is raised when you try to increment or decrement a constant value. It can also occur if you try to increment an expression such as (a+b)++
.
Make the variable non-const.
Remove the increment or decrement operator.
Store the expression in a variable, and then increment the variable.
The following example generates CS1059 because i
is a constant, not a variable, and E
is an Enum
type, whose elements are also constant values.
// CS1059.cs
class Program
{
public enum E : sbyte
{
a = 1,
b = 2
}
static void Main(string[] args)
{
const int i = 0;
i++; // CS1059
E test = E.a++; // CS1059
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: