c# - Why does Intellisense show a variable as an option on the right side of its declaration? -


in example below, visual studio gives me intellisense variable haven't finished declaring / instantiating. variable in scope , used on right side of it's own declaration? if not, why intellisense show option? quirk how intellisense works?

var myvariable1 = 1; // throws compiler error, vs offers option of type // when start typing "myv"... var myvariable2 = myvariable2;  

pic

yes, variable in scope. that's how declarations work.

ordinarily, doesn't make sense refer variable being declared in own initialiser, , local variables, compiler not allow observe value before it's initialised. use of variable doesn't rely on being initialised can show in scope. non-local variables, have default value, initialiser well-defined if refers variable.

static class program {   static int f(out int i) {     return = 0;   }   static void main() {     int = f(out i); // okay   }   static int j = j; // okay } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -