본문 바로가기

Development/c#

[C#] 현재 실행하는 메소스 정보 확인

반응형

현재 실행하는 메소스 정보를 확인해 보도록 하겠다.

using System.Reflection;

public void GetMethodInfo()
{
    Debug.WriteLine(string.Format("Class Full Name : {0}", MethodBase.GetCurrentMethod().ReflectedType.FullName));
    Debug.WriteLine(string.Format("method Name : {0}", MethodBase.GetCurrentMethod().Name));
}

/* 결과
Class Full Name : UnitTestProject.UnitTest1
method Name : GetMethodInfo
*/

 

MSDN

 

 

MethodBase.GetCurrentMethod 메서드 (System.Reflection)

실행 중인 메서드를 나타내는 MethodBase 개체를 반환합니다.Returns a MethodBase object representing the currently executing method.

docs.microsoft.com

사용 예시
 

[C#] 경과 시간 확인 하기

Log 를 생성할 경우 메소드의 경과 시간이 필요 할 경우가 있다. 이번에는 경과 시간을 확인 해 보도록 하겠다. 구문은 다음과 같다. using System.Diagnostics; public void GetElapsedTime() { Stopwatch sw =..

blissfuljoon.tistory.com

 

반응형