C# version of __FUNCTION__ macro

后端 未结 6 1813
有刺的猬
有刺的猬 2021-02-19 01:18

Does anyone has a good solution for a C# version of the C++ __FUNCTION__ macro? The compiler does not seem to like it.

6条回答
  •  悲&欢浪女
    2021-02-19 01:35

    Unfortunately there is no equivalent version of that macro in C#. I don't consider the GetCurrentMethodName() solution equivalent to the C++ __FUNCTION__ macro. Namely becase the C++ version is a compile time computation of the name. For C# this is a runtime calculation and incurs a performance hit.

    I'm not making any assumtions about the severity of the cost but there is one

提交回复
热议问题