Why is the postfix increment (++) operator not allowed after int.parse ("1")?

When you use int.Parse ("1") as the operand of the postfix increment ++ operator:

var result = int.Parse("1")++;

C # compiler shows error:

The operand of the increment or decrement operator must be a variable, property, or index.

Which I can understand for the prefix I / O operator, but not for the postfix in or decment operator. In the case of the operator prefix, there is no value for the operation, but in the case of the postfix there will always be a value. Same thing with a property that is behind the scenes of "getter" and thus returns a value in the same way (assumption not tested in IL).

What am I missing here?

+3
source share
4 answers

? .

var result = (int.Parse("1") = int.Parse("1")+1);

, ?

+12

, ++ , .

, ? , , .

, int.Parse("1") + 1

+1

, , "lvalues"; , .

(AFAIK, , ).

+1

: " , "

.

var result = int.Parse("1");
resunt += 1;
0
source

All Articles