1
public class Program
    {
        static void Main(string[] args)
        {
            MyObject object = new MyObject();
        }
    }
    public class MyObject
    {
        public MyObject()
        {
            Console.WriteLine(GetCallerClass());  // Out: 'Program'
        }
    }

Can I get class name, which called th constructor (like in my code)? I think System.Reflection can help me, but which is method I should use?

0 Answers0