Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get name of class in C#

Tags:

c#

I need to get the name of the class that I am currently in. The problem is that I am in a static property. Any idea how I can do this without a reference to this?

like image 884
user489041 Avatar asked Dec 03 '25 19:12

user489041


2 Answers

If you really want it, although as TomTom points out, you might not need it:

System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name
like image 189
George Duckett Avatar answered Dec 06 '25 09:12

George Duckett


System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name
like image 23
BlueMonkMN Avatar answered Dec 06 '25 07:12

BlueMonkMN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!