c# - Variables more local than the rest of local variables ( is it really "more local" or just "isolated" from the rest that are "as local as" it's?) -
i've got quite small , straight forward question, i'll sure answer for, , thank guys in advance:
inside method ( main instance ), can add curly braces {} section of code scope lines locals.
here's example:
public static void main (string[] args) { int = 1; { int b = 2; console.writeline(b); } console.writeline(a); }
the variable "int b" non-accessible in out side of curly braces, question variable's memory position, going in same stack frame main method in same stack of memory, or it's going held in yet newer stack frame on top of main method's stack (like called method's parameters , local variables inside method)?
no, braces not act stack frame.b
automatic variable main method & treated same a
additional scoping so,it going in same stack frame main method in same stack of memory.
Comments
Post a Comment