I have this code:
class Program
{
static void Main(string[] args)
{
Action whatToDo = () => {
var member = (MemberInfo)(MethodBase.GetCurrentMethod());
Thread.Sleep(0); //whatever, need something to put a breakpoint on
};
whatToDo();
}
}
when I run it and use watch to look inside the object bound to member
reference I see that MemberInfo.Name
property has value <Main>b__0
.
This looks weird. Why wouldn't reflection make use of whatToDo
name? What if I had more that one action with the same signature inside one member function - how would I tell which one is reported?
Why is such a weird name returned by reflection?