Possible Duplicate:
How can I find the method that called the current method?
I’d like to write a method which obtains the name of the calling method, and the name of the class containing the calling method.
Is it possible with C# reflection?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Now let’s say you have another class like this:
name will be "Call" and type will be "Caller".
UPDATE: Two years later since I’m still getting upvotes on this
In .NET 4.5 there is now a much easier way to do this. You can take advantage of the
CallerMemberNameAttribute.Going with the previous example: