System.Reflection.MethodBase.GetGenericArguments C# (CSharp) Method

GetGenericArguments() public method

Returns an array of T:System.Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition.
The current object is a . Generic constructors are not supported in the .NET Framework version 2.0. This exception is the default behavior if this method is not overridden in a derived class.
public GetGenericArguments ( ) : System.Type[]
return System.Type[]
        public virtual Type[] GetGenericArguments()
        {
            throw new NotImplementedException();
        }

Usage Example

 protected virtual string FormatMethod(MethodBase method)
 {
     var sb = new StringBuilder();
     if (method.DeclaringType != null)
     {
         sb.Append(method.DeclaringType.FullName);
         sb.Append(".");
     }
     sb.Append(method.Name);
     if (method.IsGenericMethod)
     {
         sb.Append("<");
         sb.Append(string.Join(", ", method.GetGenericArguments().Select(t => t.Name)));
         sb.Append(">");
     }
     sb.Append("(");
     var f = false;
     foreach (var p in method.GetParameters())
     {
         if (f) sb.Append(", ");
         else f = true;
         sb.Append(p.ParameterType.Name);
         sb.Append(' ');
         sb.Append(p.Name);
     }
     sb.Append(")");
     return sb.ToString();
 }
All Usage Examples Of System.Reflection.MethodBase::GetGenericArguments