Maha

Maha

  • NA
  • 0
  • 328.3k

NP102 Please correct it

Jun 18 2008 6:54 PM

Hi Guys

 

NP102 Please correct it

 

http://www.aspfree.com/c/a/C-Sharp/C-sharp-Methods-part-1/4/

 

I got the following program from the above website. Output expected from the program is:

 

Void Main(System.String[])

Void Method1()

Void Method2()

Void Method3()

Void Method4()

 

But program is giving different output please correct it.

 

Thank you

 

 

using System;

using System.Diagnostics;

 

namespace Methods

{

    class Class1

    {

 

        static void Main(string[] args)

        {

            Method1();

            Console.ReadLine();

        }

 

        static void Method1()

        {

            Method2();

        }

 

        static void Method2()

        {

            Method3();

        }

 

        static void Method3()

        {

            Method4();

        }

 

        static void Method4()

        {

            StackTrace st = new StackTrace();

 

            for (int i = st.FrameCount - 1; i >= 0; i--)

            {

                StackFrame sf = new StackFrame();

                sf = st.GetFrame(i);

                Console.WriteLine(sf.GetMethod());

            }

        }

    }

}


Answers (6)