You need to look at the MethodBody class (there is a very good example of using it in a link). This will allow you to write code, for example:
MethodInfo mi = typeof(A).GetMethod("DoStuff");
MethodBody mb = mi.GetMethodBody();
foreach (LocalVariableInfo lvi in mb.LocalVariables)
{
if (lvi.LocalType == typeof(B))
Console.WriteLine("It uses a B!");
if (lvi.LocalType == typeof(C))
Console.WriteLine("It uses a C!");
}
source
share