DEV Community

Discussion on: Who am I? Me, the name of the currently executing method in C#

Collapse
 
thebuzzsaw profile image
Kelly Brown

Get the name at compile-time instead!

public static string? Me([CallerMemberName] string? cmn = null) => cmn;
Collapse
 
bugmagnet profile image
Bruce Axtens

Can't wait to try it. A pity I can only click the <3 button once.

Collapse
 
bugmagnet profile image
Bruce Axtens

Needs using System.Runtime.CompilerServices; or public static string? Me([System.Runtime.CompilerServices.CallerMemberName] string? cmn = null) => cmn;