ECMA-334: 12.3.3.22 Simple assignment expressions

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
C# Language Specification
© 2006 ECMA International

12.3.3.22 Simple assignment expressions

For an expression expr of the form w = expr-rhs:

  • The definite assignment state of v before w is the same as the definite assignment state of v before expr.
  • The definite assignment state of v before expr-rhs is the same as the definite assignment state of v after w.
  • If w is the same variable as v, then the definite assignment state of v after expr is definitely assigned. Otherwise, the definite assignment state of v after expr is the same as the definite assignment state of v after expr-rhs.

[Example: In the following code

class A
{
  static void F(int[] arr)
  {
    int x;
    arr[x = 1] = x; // ok
  }
}

the variable x is considered definitely assigned after arr[x = 1] is evaluated as the left hand side of the second simple assignment. end example]


Today's Deals: Electronics

Personal tools