Thinker
Expression vs Statement vs Expression statement in programming
However, when you call a method, that might do something, but it may also return a value! That is why we can call methods both as statements and as expressions, eg. we can call a method like
int x = DoSomething() + 1;
but also as DoSomething();
. When we specifically use a method call as a statement, that is called an expression statement.20 replies
Expression vs Statement vs Expression statement in programming
A statement is something which does something, for instance
Console.WriteLine
writes to the console.
An expression is something which returns a value, for instance x + 1
returns the value contained within x
plus 1.20 replies