StackFrame.ToString メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > StackFrame.ToString メソッドの意味・解説 

StackFrame.ToString メソッド

スタック トレース読み取り可能な形式構築します

名前空間: System.Diagnostics
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

使用例使用例

ToString メソッド使用する方法次のコード例示します

Public Sub InternalMethod()
   Try
      Dim nestedClass As New
 ClassLevel2
      nestedClass.Level2Method()
   Catch e As Exception
      Console.WriteLine(" InternalMethod exception handler")
      
      ' Build a stack trace from one frame, skipping the 
      ' current frame and using the next frame.  By default,
      ' file and line information are not displayed.
      Dim st As New StackTrace(New
 StackFrame(1))
      Console.WriteLine(" Stack trace for next level frame: {0}",
 _
         st.ToString())
      Console.WriteLine(" Stack frame for next level: ")
      Console.WriteLine("   {0}", st.GetFrame(0).ToString())
      
      Console.WriteLine(" Line Number: {0}", _
         st.GetFrame(0).GetFileLineNumber().ToString())
      
      Console.WriteLine()
      Console.WriteLine("   ... throwing exception to next level
 ...")
      Console.WriteLine("-------------------------------------------------")
      Console.WriteLine()
      Throw e
   End Try
End Sub 'InternalMethod
public void InternalMethod()
{
   try
   {
      ClassLevel2 nestedClass = new ClassLevel2();
      nestedClass.Level2Method();
   }
   catch (Exception e)
   {
      Console.WriteLine(" InternalMethod exception handler");

      // Build a stack trace from one frame, skipping the
      // current frame and using the next frame.  By
      // default, file and line information are not displayed.
      StackTrace st = new StackTrace(new StackFrame(1));
      Console.WriteLine(" Stack trace for next level frame:
 {0}",
         st.ToString());
      Console.WriteLine(" Stack frame for next level: ");
      Console.WriteLine("   {0}", st.GetFrame(0).ToString());

      Console.WriteLine(" Line Number: {0}",
         st.GetFrame(0).GetFileLineNumber().ToString());

      Console.WriteLine();
      Console.WriteLine("   ... throwing exception to next level ...");
      Console.WriteLine("-------------------------------------------------\n");
      throw e;
   }
}
void InternalMethod()
{
   try
   {
      ClassLevel2^ nestedClass = gcnew ClassLevel2;
      nestedClass->Level2Method();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( " InternalMethod exception handler" );
      
      // Build a stack trace from one frame, skipping the
      // current frame and using the next frame.  By
      // default, file and line information are not displayed.
      StackTrace^ st = gcnew StackTrace( gcnew StackFrame( 1 ) );
      Console::WriteLine( " Stack trace for next level frame:
 {0}", st->ToString() );
      Console::WriteLine( " Stack frame for next level: "
 );
      Console::WriteLine( "   {0}", st->GetFrame( 0 )->ToString()
 );
      Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString()
 );
      Console::WriteLine();
      Console::WriteLine( "   ... throwing exception to next level ..."
 );
      Console::WriteLine( "-------------------------------------------------\n"
 );
      throw e;
   }

}

public void InternalMethod() throws System.Exception
{
    try {
        ClassLevel2 nestedClass = new ClassLevel2();
        nestedClass.Level2Method();
    }
    catch (System.Exception e) {
        Console.WriteLine(" InternalMethod exception handler");

        // Build a stack trace from one frame, skipping the
        // current frame and using the next frame.  By
        // default, file and line information are not displayed.

        StackTrace st = new StackTrace(new
 StackFrame(1));
        Console.WriteLine(" Stack trace for next level frame:
 {0}", 
            st.ToString());
        Console.WriteLine(" Stack frame for next level: ");
        Console.WriteLine("   {0}", st.GetFrame(0).ToString());
        Console.WriteLine(" Line Number: {0}", 
            Convert.ToString(st.GetFrame(0).GetFileLineNumber()));
        Console.WriteLine();
        Console.WriteLine(" ... throwing exception to next level...");
        Console.WriteLine("-------------------------------------------"
            + "------\n");
        throw e;
    }
} //InternalMethod
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

StackFrame.ToString メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StackFrame.ToString メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS