-
C# CallerMemberNameAttribute Class 소개.NET/C# Basic 2016. 2. 29. 15:56반응형
https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.callermembernameattribute(v=vs.110).aspx
Available since 4.5
public void DoProcessing() { TraceMessage("Something happened."); } public void TraceMessage(string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0) { System.Diagnostics.Trace.WriteLine("message: " + message); System.Diagnostics.Trace.WriteLine("member name: " + memberName); System.Diagnostics.Trace.WriteLine("source file path: " + sourceFilePath); System.Diagnostics.Trace.WriteLine("source line number: " + sourceLineNumber); } // Sample Output: // message: Something happened. // member name: DoProcessing // source file path: c:\Users\username\Documents\Visual Studio 2012\Projects\CallerInfoCS\CallerInfoCS\Form1.cs // source line number: 31
반응형'.NET > C# Basic' 카테고리의 다른 글
IIS HTTPS 세팅하기 및 C# 사설 SSL 인증서 호출 사용하기 OPENSSL 사용하기 (0) 2023.03.14 C# Custom Sort Null 널값이 제일 아래로 IComparer IComparable (2) 2013.08.23 DLL Ressource 에서 BitmapImage 불러오기 Method (1) 2013.01.11 Visual Studio 2005의 원격 디버깅 설정(http://www.hoonsbara.com/) (1) 2010.06.14 [C#] String.Format 을 이용한 문자정렬 왼쪽 오른쪽 가운데 | String alignment Left Right Center (0) 2010.03.20 [C#] char[] + char[] = char[]?? | char[] Merge (0) 2010.02.09 [C#] Thread를 정복해 보자 (0) 2010.02.06 사용예) StringCollection 과 string[] int[] converterMethod (0) 2010.02.02