SHARE
TWEET

selfelected

a guest Jan 16th, 2010 366 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     class ReflectionUtility
  2.     {
  3.         private static System.Reflection.MethodBase GetCallingMethod()
  4.         {
  5.             return new System.Diagnostics.StackTrace().GetFrame(2).GetMethod();
  6.         }
  7.         public static string GetCallingMethodFullNameReturnParametertypes()
  8.         {
  9.             return MethodFullNameReturnParametertypes(GetCallingMethod());
  10.         }
  11.         private static string MethodFullNameReturnParametertypes(System.Reflection.MethodBase method)
  12.         {
  13.             return string.Format("{0} {1}.{2} ({3})",
  14.                 ((System.Reflection.MethodInfo)method).ReturnType,    // System.Void, System.Int32 etc.
  15.                 method.DeclaringType.FullName,   // MyNamespace.MyClass.
  16.                 method.Name,   // MyMethod.
  17.                 string.Join(",", method.GetParameters().Select(p => p.ParameterType.ToString() + " " + p.Name).ToArray())   // () or (int) or (int,string) etc.
  18.                 );
  19.         }
  20.     }
RAW Paste Data
Want to get better at C#?
Learn to code C# in 2017
Top