System.Diagnostics.StackTrace.GetFrame C# (CSharp) Method

GetFrame() public method

public GetFrame ( int index ) : System.Diagnostics.StackFrame
index int
return System.Diagnostics.StackFrame
        public virtual System.Diagnostics.StackFrame GetFrame(int index) { throw null; }
        public override string ToString() { throw null; }

Usage Example

Esempio n. 1
0
        /**
         * Retorna o nome do metodo e da classe chamada
         * param frame: Indice do frame na pilha de execucao do qual se deseja extrair o nome do metodo e da classe
         * Obs: o indice 0 representa o metodo atual, 1 representa quem chamou este metodo e assim por diante
         */
        public static void GetCalledMethod(out string MethodName, out string ClassName, int frame = 2)
        {
            StackTrace stackTrace = new StackTrace();

            MethodName = stackTrace.GetFrame(frame).GetMethod().Name;
            ClassName = stackTrace.GetFrame(frame).GetMethod().DeclaringType.Name;
        }
All Usage Examples Of System.Diagnostics.StackTrace::GetFrame