In .NET 4.5 / C# 5, this is simple:
public void PopularMethod([CallerMemberName] string caller = null)
{
// look at caller
}
The compiler adds the caller’s name automatically; so:
void Foo() {
PopularMethod();
}
will pass in "Foo".
In .NET 4.5 / C# 5, this is simple:
public void PopularMethod([CallerMemberName] string caller = null)
{
// look at caller
}
The compiler adds the caller’s name automatically; so:
void Foo() {
PopularMethod();
}
will pass in "Foo".