SORU
25 Temmuz 2010, Pazar


C# özel durum hangi elde satır numarası

catch bir blok içinde, nasıl bir özel durum hangi satır numarasını alabilir miyim?

CEVAP
25 Temmuz 2010, Pazar


Eğer sadece daha fazla izleme biçimlendirilmiş yığın satır numarasını ihtiyacınız varsa İstisna olsun.StackTrace, StackTrace sınıfını kullanabilirsiniz:

try
{
    throw new Exception();
}
catch (Exception ex)
{
    // Get stack trace for the exception with source file information
    var st = new StackTrace(ex, true);
    // Get the top stack frame
    var frame = st.GetFrame(0);
    // Get the line number from the stack frame
    var line = frame.GetFileLineNumber();
}

Bu eğer bir pdb dosyası Meclisi varsa orada sadece çalışacağını unutmayın.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Kanál používateľa McsFuego

    Kanál použ

    12 EKİM 2011
  • Tutorials Junction

    Tutorials Ju

    1 Ocak 2014
  • Xcode programming tutorials

    Xcode progra

    17 EYLÜL 2006