Created
January 11, 2018 22:50
-
-
Save rfum/be82cc23af835562c334ad75539e7fd2 to your computer and use it in GitHub Desktop.
StackTrace C# Örnek
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace StackTrace | |
{ | |
class Program | |
{ | |
static void Main(string [] args) | |
{ | |
A(); | |
} | |
static void A() {B();} | |
static void B() {C();} | |
static void C() | |
{ | |
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(true);//stacktrace sınıfından bir obje oluşuturuldu true flagi ile scope data alındı | |
int lineNumber = st.FrameCount;//toplam metod sayısı-threade ait- | |
for (int i = 0; i < lineNumber; i++)//frameler arası iterasyon | |
{ | |
Console.WriteLine($"[DosyaAdı] : {st.GetFrame(i).GetFileName()} [MetodAdı] : {st.GetFrame(i).GetMethod().Name} " + | |
$"[SatırNo] : { st.GetFrame(i).GetFileLineNumber() } [KolonNo] : {st.GetFrame(i).GetFileColumnNumber()}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment