mardi 26 novembre 2019

A shorter way to write System.Reflection.MethodBase.GetCurrentMethod.Name?

I've been focusing on logging more lately. I really do appreciate getting the method name in the logger. My only issue is that the reflective method is so long to write.

I tested with static classes and a method for it. But to my not so big surprise, it gave me the name of the static class method.

So far the only way I found to shorten it a bit is

using Info = System.Reflection.MethodBase;
string name = Info.GetCurrentMethod().Name;

Is there a way to shorten this to something like Info.MethodName()?





Aucun commentaire:

Enregistrer un commentaire