StackFrame.GetMethod Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the method in which the frame is executing.
public:
System::Reflection::MethodBase ^ GetMethod();
public:
virtual System::Reflection::MethodBase ^ GetMethod();
public System.Reflection.MethodBase GetMethod ();
public virtual System.Reflection.MethodBase? GetMethod ();
public virtual System.Reflection.MethodBase GetMethod ();
member this.GetMethod : unit -> System.Reflection.MethodBase
abstract member GetMethod : unit -> System.Reflection.MethodBase
override this.GetMethod : unit -> System.Reflection.MethodBase
Public Function GetMethod () As MethodBase
Public Overridable Function GetMethod () As MethodBase
Returns
The method in which the frame is executing.
Examples
The following example demonstrates the use of the GetMethod method. This code example is part of a larger example provided for the StackFrame class.
StackFrame^ fr = gcnew StackFrame( 1,true );
StackTrace^ st = gcnew StackTrace( fr );
EventLog::WriteEntry( fr->GetMethod()->Name, st->ToString(), EventLogEntryType::Warning );
StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
st.ToString(),
EventLogEntryType.Warning);
Dim frame As New StackFrame(1, True)
Dim strace As New StackTrace(frame)
EventLog.WriteEntry(frame.GetMethod().Name, _
strace.ToString(), _
EventLogEntryType.Warning)
Remarks
The method that is currently executing may be inherited from a base class, although it is called in a derived class. In this case, the ReflectedType property of the MethodBase object that is returned by GetMethod identifies the base class, not the derived class.
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om