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

后端 未结 4 2301
走了就别回头了
走了就别回头了 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:10

    I think this is because the variable name you see in ILDasm come from the pdb file, not from the assembly itself. If you want to get them, you'll need to read the pdb too.

提交回复
热议问题