Why is it not possible to get local variable names using Reflection?

后端 未结 4 2331
走了就别回头了
走了就别回头了 2021-02-20 13:33

If I have a code like this:

public class Program
{
    public static void Main()
    {
        string bar = \"\";
        int foo = 24;
    }
}

4条回答
  •  遇见更好的自我
    2021-02-20 14:17

    From MSDN:

    Local variable names are not persisted in metadata. In Microsoft intermediate language (MSIL), local variables are accessed by their position in the local variable signature.

提交回复
热议问题