Decaration Versus (Simple) Assignment
It’s important to realize the fundamental difference between declaring variables and assigning to them. Declaring a variable simply introduces a symbolic name (specified using an identifier) in the containing scope, also specifying its type. Assignment is the act of setting a value for the variable, which can be done multiple times as long as the variable is in scope (unless the variable is declared as constant, that is). The following piece of code
int x = 42;
can be decomposed into two separate discrete steps:
int x;x = 42;
The latter one is what we’re talking about here. It’s called a simple assignment that has the form lhs = rhs. After evaluating the right side (rhs), it gets assigned to the left side ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.