StackFrame.GetFileLineNumber 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得檔案中的行號,含有正在執行的程式碼。 這項資訊通常擷取自可執行檔的偵錯符號。
public:
int GetFileLineNumber();
public:
virtual int GetFileLineNumber();
public int GetFileLineNumber ();
public virtual int GetFileLineNumber ();
member this.GetFileLineNumber : unit -> int
abstract member GetFileLineNumber : unit -> int
override this.GetFileLineNumber : unit -> int
Public Function GetFileLineNumber () As Integer
Public Overridable Function GetFileLineNumber () As Integer
傳回
檔案行號,如果無法確定檔案行號則為 0 (零)。
範例
下列範例示範 GetFileLineNumber 方法的用法。 此程式代碼範例是針對 類別提供的較大範例的 StackFrame 一部分。
// Display the stack frame properties.
StackFrame^ sf = st->GetFrame( i );
Console::WriteLine( " File: {0}", sf->GetFileName() );
Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
// Note that the column number defaults to zero
// when not initialized.
Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() );
Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() );
// Display the stack frame properties.
StackFrame sf = st.GetFrame(i);
Console.WriteLine(" File: {0}", sf.GetFileName());
Console.WriteLine(" Line Number: {0}",
sf.GetFileLineNumber());
// Note that the column number defaults to zero
// when not initialized.
Console.WriteLine(" Column Number: {0}",
sf.GetFileColumnNumber());
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
Console.WriteLine(" Intermediate Language Offset: {0}",
sf.GetILOffset());
}
if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN)
{
Console.WriteLine(" Native Offset: {0}",
sf.GetNativeOffset());
}
' Display the stack frame properties.
Dim sf As StackFrame = st.GetFrame(i)
Console.WriteLine(" File: {0}", sf.GetFileName())
Console.WriteLine(" Line Number: {0}", _
sf.GetFileLineNumber())
' The column number defaults to zero when not initialized.
Console.WriteLine(" Column Number: {0}", _
sf.GetFileColumnNumber())
If sf.GetILOffset <> StackFrame.OFFSET_UNKNOWN
Console.WriteLine(" Intermediate Language Offset: {0}", _
sf.GetILOffset())
End If
If sf.GetNativeOffset <> StackFrame.OFFSET_UNKNOWN
Console.WriteLine(" Native Offset: {0}", _
sf.GetNativeOffset())
End If