Yes! The MethodBase class's static GetCurrentMethod will inspect the calling code to see if it's a constructor or a normal method, and returns either a MethodInfo or a ConstructorInfo.
This namespace is a part of the reflection API, so you can basically discover everything that the run-time can see by using it.
Here you will find an exhaustive description of the API:
http://msdn.microsoft.com/en-us/library/system.reflection.aspx
If you don't feel like looking through that entire library here is an example I cooked up:
namespace Canvas
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod());
DiscreteMathOperations viola = new DiscreteMathOperations();
int resultOfSummation = 0;
resultOfSummation = viola.ConsecutiveIntegerSummation(1, 100);
Console.WriteLine(resultOfSummation);
}
}
public class DiscreteMathOperations
{
public int ConsecutiveIntegerSummation(int startingNumber, int endingNumber)
{
Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod());
int result = 0;
result = (startingNumber * (endingNumber + 1)) / 2;
return result;
}
}
}
The output of this code will be:
Void Main<System.String[]> // Call to GetCurrentMethod() from Main.
Int32 ConsecutiveIntegerSummation<Int32, Int32> //Call from summation method.
50 // Result of summation.
Hope I helped you!
JAL