title: CS1023 Embedded statement cannot be a declaration or labeled statement
body: <p>I have a programm which works correctly. This a correct code.</p>
  
  <pre><code>public static double Smth(int x, int y, double[,] original, int lengthX, int lengthY)
          {
              var pixelsFields = new List&lt;double&gt;();
              double median;
              for (int areasX = -1; areasX &lt; 2; areasX++)
                  for (int areasY = -1; areasY &lt; 2; areasY++)
                      if ((x + areasX &gt; -1) &amp;&amp; (y + areasY &gt; -1) &amp;&amp; (x + areasX &lt; lengthX) &amp;&amp; (y + areasY &lt; lengthY))
                          pixelsFields.Add(original[x + areasX, y + areasY]);
  </code></pre>
  
  <p>However, I would like to improve my code. Expressions "x + areasX" and "y + areasY" repeat often, so I decided to create two variables. Unfortunately, I have an error on new variables: "error CS1023: Embedded statement cannot be a declaration or labeled statement".   </p>
  
  <pre><code>public static double Smth(int x, int y, double[,] original, int lengthX, int lengthY)
              {
                  var pixelsFields = new List&lt;double&gt;();
                  double median;
                  for (int areasX = -1; areasX &lt; 2; areasX++)
                      for (int areasY = -1; areasY &lt; 2; areasY++)
                          var diffX = x + areasX;
                          var diffY = y + areasY;
                          if ((diffX &gt; -1) &amp;&amp; (diffY &gt; -1) &amp;&amp; (diffX &lt; lengthX) &amp;&amp; (diffY &lt; lengthY))
                              pixelsFields.Add(original[diffX, diffY]);
  </code></pre>
  
  <p>Could you help me and correct? </p>