StackFrame.GetMethod Method
In this article
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
The method in which the frame is executing.
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)
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
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: