C#
[C#] 현재 메소드 이름 얻기 ( MethodBase.GetCurrentMethod() )
HyoSeong
2021. 1. 11. 16:37
반응형
결론부터 알려드리겠습니다.
public void MyMethod() {
Console.WriteLine(MethodBase.GetCurrentMethod().Name);
// output : MyMethod
}
GetCurrentMethod라는 함수를 사용하면 MethodBase 객체를 얻을 수 있습니다.
MethodBase객체에는 다음과 같은 값이 있습니다.
해당 속성은 주로 Logging을 할 때 사용됩니다.
감사합니다.
반응형