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

  • captainpuppys2000

    captainpuppy

    20 HAZİRAN 2013
  • DrakeVEVO

    DrakeVEVO

    17 AĞUSTOS 2009
  • Garrett Müller

    Garrett Mül

    26 HAZİRAN 2009