You can try: using System. Diagnostics; StackTrace stackTrace = new StackTrace(); Console. WriteLine(stackTrace.
GetFrame(1).GetMethod(). Name).
Thanks! It works just fine. – Binder Aug 10 '09 at 12:31 +1: cool, didn't know that – Juri Aug 10 '09 at 12:33 weichsel this one is good..! +1 from my side..! Although this thread is a bit old but definitely useful..! :) – samar Dec 16 '10 at 12:24.
I think you are looking for: using System. Diagnostics; StackTrace stackTrace = new StackTrace(); stackTrace. GetFrame(1).GetMethod().Name.
1 Duplicate of higher voted older item (and also -1d the question on the same basis) – Ruben Bartelink Oct 15 '10 at 14:43 @Ruben - Never realised someone posting an answer faster than you deserved a downvote! – James Oct 15 '10 at 14:48 I understand, and this isnt the first time people have rejected my analysis. If the answer didn't have an upvote, I wouldnt downvote.
I know that's inconsistent under reducto ad absurdum. (The other question has better answers - I was looking for an answer that covered the NoInlining point and syntax). (I personally either delete dups I create or edit them to become different and/or better than the other answers - if someone else covered the same ground before me, I'm happy to have it pointed out and/or get downvoted).
– Ruben Bartelink Oct 15 '10 at 14:53.
You can do this by displaying the call stack. This will find the entire call stack, not just the calling method though. Void displaycallstack() { byte b; StackFrame sf; MemoryStream ms = new MemoryStream(); String s = Process.
GetCurrentProcess(). ProcessName; Console.Out. WriteLine(s + " Call Stack"); StackTrace st = new StackTrace(); for(int a = 0;a FrameCount;a++) { sf = st.
GetFrame(a); s = sf.ToString(); be = Encoding.ASCII. GetBytes(s); ms. Write(b,0,b.
Length); } ms. WriteTo(System.Console. OpenStandardOutput()); }.
Whau, that is probably the most interesting way I have ever seen anyone write to the console :-) – Jørn Schou-Rode Aug 10 '09 at 12:14 That looks like complicator code... thedailywtf. Com/Articles/The_Complicator_0x27_s_Gloves. Aspx – Greg D Aug 10 '09 at 12:22 Jorn, after looking at the code a little more closely.. I'd have to agree.It was just taken from an example on how to display the stack trace.
I'll have to find better examples next time :) – daed Aug 10 '09 at 12:45.
Check the System.Diagnostics. Trace class, but as far as I know - there is performance price when using it.
Better not to use StackFrame, becouse there are some . NET security issues - if code not fully trusted expression "new StackFrame()" will throw security exception. To get current method use MethodBase.
GetCurrentMethod(). Name About getting calling method see: Getting calling method owner.
Thank ALor, but I guess you missed the point. I don't want the current method name, I need the method name of the method that called the current method. :) – Binder Aug 11 '09 at 11:35 I recently asked same question ;) There are lot of problems with StackFrame - if calling method gets inlined by JIT, you will get wrong results; – ALOR Aug 11 '09 at 15:33.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.