title: How to find the parent method name in multiple sub methods in C#?
body: <p>I'm trying to get the very first method name that initialed multiple method calls. </p>
  
  <p>for example I have the below,  </p>
  
  <pre><code>    static void Main(string[] args)
      {
          Test1();
      }
  
      static void Test1()
      {
          Test2();
      }
      static void Test2()
      {
          Console.WriteLine("Soemthing");
      }
  </code></pre>
  
  <p>In the Test2 method, I need to know the Main Method has initiated this chain. 
  I tried using the StackTrace and Reflection as below. </p>
  
  <pre><code>        StackTrace stackTrace = new StackTrace();
          MethodBase methodBase = stackTrace.GetFrame(1).GetMethod();
          Console.WriteLine(methodBase.Name); 
  </code></pre>
  
  <p>but the <strong>stackTrace.getFrame(1)</strong> is not what I expect. It will give me the previous method which is Test1. </p>
  
  <p>I do not want to hard code the getFrame value to <strong>2</strong> to get the Main method. </p>
  
  <p>Is there any way to get the parent method from any of the sub methods without hard coding the Frame value?   </p>