What are rvalue and lvalue in C#?


The following are the types of expressions in C# −

  • lvalue − An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment.

  • rvalue − An expression that is an rvalue may appear on the right- but not left-hand side of an assignment.

Variables are lvalues and hence they may appear on the left-hand side of an assignment. Numeric literals are rvalues and hence they may not be assigned and cannot appear on the left-hand side.

Here is a valid C# statement −

int a = 100:

Updated on: 21-Jun-2020

614 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements