c# print the class name from within a static function

前端 未结 7 783
囚心锁ツ
囚心锁ツ 2021-02-06 23:19

Is it possible to print the class name from within a static function?

e.g ...

public class foo
{

    static void printName()
    {
        // Print the          


        
相关标签:
7条回答
  • 2021-02-07 00:02

    While the StackTrace answers are correct, they do have an overhead. If you simply want safety against changing the name, consider typeof(foo).Name. Since static methods can't be virtual, this should usually be fine.

    0 讨论(0)
提交回复
热议问题