This documentation is archived and is not being maintained.

StackFrame.GetMethod Method

Gets the method in which the frame is executing.

[Visual Basic]
Public Overridable Function GetMethod() As MethodBase
[C#]
public virtual MethodBase GetMethod();
[C++]
public: virtual MethodBase* GetMethod();
[JScript]
public function GetMethod() : MethodBase;

Return Value

The method in which the frame is executing.

Example

[Visual Basic, C#, C++] The following code example demonstrates how you can use the GetMethod method.

[Visual Basic] 
Dim frame As New StackFrame(1, True)
Dim strace As New StackTrace(frame)            

EventLog.WriteEntry(frame.GetMethod().Name, _
                    strace.ToString(), _
                    EventLogEntryType.Warning)

[C#] 
StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
                    st.ToString(),
                    EventLogEntryType.Warning);

[C++] 
StackFrame* fr = new StackFrame(1, true);
StackTrace* st = new StackTrace(fr);
EventLog::WriteEntry(fr->GetMethod()->Name,
    st->ToString(), EventLogEntryType::Warning);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

StackFrame Class | StackFrame Members | System.Diagnostics Namespace

Show: