Skip to content
Discussion options

You must be logged in to vote

IL has no scoping of locals, they are all declared up front:

    .method private hidebysig static 
        void Main (
            string[] args
        ) cil managed 
    {
        .maxstack 2
        .locals init (
            [0] int32 outer,
            [1] int32 inner,
            [2] int32 deeper
        )
    }

There can be a 1-to-1 mapping of C# locals to IL locals, although the compiler can decide to reuse local slots if it wants to.

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@The-Futurist
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by The-Futurist
Comment options

You must be logged in to vote
1 reply
@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
1 reply
@HaloFour
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants