MethodInfo Referenz auf aktuell ausgeführte Methode bekommen

Thomas Darimont

Erfahrenes Mitglied
Hallo,

Schaut mal hier:
C#:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;


namespace De.Tutorials.Training
{
    public class CurrentMethodExample
    {
        public static void Main(string[] args)
        {
            A();
        }

        private static void A()
        {
            B();
        }

        private static void B()
        {
            C();
        }

        private static void C()
        {
            Console.WriteLine("Currently executing: "+MethodInfo.GetCurrentMethod().Name);
        }
    }
}

Ausgabe:
Code:
Currently executing: C
Drücken Sie eine beliebige Taste . . .

Gruß Tom
 
Zurück