Get types used inside a C# method body

后端 未结 7 855
鱼传尺愫
鱼传尺愫 2020-12-01 16:12

Is there a way to get all types used inside C# method?

For example,

public int foo(string str)
{
    Bar bar = new Bar();
    string x = \"test\";
           


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-01 17:12

    With reflection you can get the method. This returns a MethodInfo object, and with this object you cannot get the types which are used in the method. So I think the answer is that you cannot get this native in C#.

提交回复
热议问题