나는 방법이있다. 조건을 확인하고 싶습니다. 내 조건 결과가 true이면 새 예외가 발생합니다. 메시지 예외를위한 메서드의 이름을 지정해야합니다. 예 :방법의 메서드 이름을 얻는 방법
public void MyMethod(Notifier not)
{
if(not.HasValue())
throw new Exception("MyMethod_name : " + not.Value);
}
메소드에서 메소드의 이름을 가져 오는 방법은 무엇입니까?
[C#의 호출 된 함수에서 호출 함수 이름 가져 오기] (http://stackoverflow.com/questions/1310145/get-calling-function-name-from-called-function -in-c-sharp) –
도 참조하십시오 http://stackoverflow.com/questions/44153/can-you-use-reflection-to-find-the-name-of-the-currently-exe cuting-method – kmote
.net 4.5 베타 +를 사용하는 경우 [CallerInformation API] (http://msdn.microsoft.com/en-us/library/hh534540%28v=vs.110%29.aspx)를 사용할 수 있습니다. . –