Reflection mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 This type is safe for multithreaded operations. System.Reflection.MethodBase System.Runtime.InteropServices._MethodInfo System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None) System.Runtime.InteropServices.ComDefaultInterface(typeof(System.Runtime.InteropServices._MethodInfo)) System.Runtime.InteropServices.ComVisible(true)

Discovers the attributes of a method and provides access to method metadata.

Instances of are obtained by calling the or method of a object or of an object that derives from , or by calling the method of a that represents a generic method definition.

For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

When operating on the given kinds of methods, the following properties return the result as shown:

Property
Non-Generic Open Generic Closed Generic
False True False
False True False
False True True Requires permission to reflect non-public members of a type in loaded assemblies. See .
- Constructor

  Constructs a new instance of the class.

  To be added.
  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Property
  System.Boolean

  Gets a value that indicates whether a generic method contains unassigned generic type parameters.

  if the contains unassigned generic type parameters; otherwise .

  In order to invoke a generic method, there must be no generic type definitions or open constructed types in the type arguments of the method itself, or in any enclosing types. If the property returns , the method cannot be invoked.

  The property searches recursively for type parameters. For example, it returns true for any method in an open type , even though the method itself is not generic. Contrast this with the behavior of the property, which returns false for such a method.

  For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

  This property is read-only.

  2.0.0.0
- Method
  4.0.0.0
  System.Boolean `` To be added. To be added. To be added. To be added.
- Method
  System.Reflection.MethodInfo

  Returns a new instance that reflects the first definition of the method reflected by the current instance in the inheritance hierarchy of that method.

  A new instance that reflects the first definition of the method reflected by the current instance in the inheritance hierarchy of that method.

  proceeds along the inheritance hierarchy of the method reflected by the current instance, returning a instance that reflects the first definition in the hierarchy of that method.

  The method declaration to be reflected by the new instance is determined as follows:

  If the method reflected by the current instance overrides a virtual definition in the base class, the virtual definition is reflected.

  If the method reflected

  by the current instance is specified with the keyword, the current instance is returned.

  If the method reflected by the current instance is not defined in the type of the object on which is called, the method definition of the furthest ancestor in the class hierarchy is reflected.
  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Method
  System.Type[]

  Returns an array of objects that represent the type arguments of a generic method or the type parameters of a generic method definition.

  An array of objects that represent the type arguments of a generic method or the type parameters of a generic method definition. Returns an empty array if the current method is not a generic method.

  The elements of the returned array are in the order in which they appear in the list of type parameters for the generic method.

  If the current method is a closed constructed method (that is, the property returns ), the array returned by the method contains the types that have been assigned to the generic type parameters of the generic method definition.

  If the current method is a generic method definition, the array contains the type parameters.

  If the current method is an open constructed method (that is, the property returns ) in which specific types have been assigned to some type parameters and type parameters of enclosing generic types have been assigned to other type parameters, the array contains both types and type parameters. Use the property to tell them apart.

  For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

  The following code shows how to get the type arguments of a generic method and display them. (It is part of a larger example for the method .)

  `// If this is a generic method, display its type arguments. // if (mi.IsGenericMethod) { Type[] typeArguments = mi.GetGenericArguments(); Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length); foreach (Type tParam in typeArguments) { // IsGenericParameter is true only for generic type // parameters. // if (tParam.IsGenericParameter) { Console.WriteLine("\t\t{0} (unbound - parameter position {1})", tParam, tParam.GenericParameterPosition); } else { Console.WriteLine("\t\t{0}", tParam); } } } else { Console.WriteLine("\tThis is not a generic method."); } }` 2.0.0.0 4.0.0.0 System.Runtime.InteropServices.ComVisible(true)
- Method
  System.Reflection.MethodInfo

  Returns a object that represents a generic method definition from which the current method can be constructed.

  A object representing a generic method definition from which the current method can be constructed.

  If you call on a that already represents a generic method definition, it returns the current .

  If a generic method definition includes generic parameters of the declaring type, there will be a generic method definition specific to each constructed type.

  A generic method definition is a template from which methods can be constructed. For example, from the generic method definition you can construct and invoke the method . Given a object representing this constructed method, the method returns the generic method definition.

  If two constructed methods are created from the same generic method definition, the method returns the same object for both methods.

  If you call on a that already represents a generic method definition, it returns the current .

  If a generic method definition includes generic parameters of the declaring type, there will be a generic method definition specific to each constructed type. For example, consider the following C# code:

  In the constructed type , the generic method returns . In the open type , returns . In both cases, the property returns true for the that represents , so can be called on both objects. In the case of the constructed type, the result of calling is a that can be invoked. In the case of the open type, the returned by cannot be invoked.

  For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

  The current method is not a generic method. That is, returns .

  The following code shows a class with a generic method and the code required to obtain a for the method, bind the method to type arguments, and get the original generic type definition back from the bound method. (It is part of a larger example for the method .)

  `// Define a class with a generic method. public class Example { public static void Generic<T>(T toDisplay) { Console.WriteLine("\nHere it is: {0}", toDisplay); } } // ... // Create a Type object representing class Example, and // get a MethodInfo representing the generic method. // Type ex = Type.GetType("Example"); MethodInfo mi = ex.GetMethod("Generic"); DisplayGenericMethodInfo(mi); // Bind the type parameter of the Example method to // type int. // Type[] arguments = {typeof(int)}; MethodInfo miBound = mi.MakeGenericMethod(arguments); DisplayGenericMethodInfo(miBound); // ... // Get the generic type definition from the closed method, // and show it's the same as the original definition. // MethodInfo miDef = miBound.GetGenericMethodDefinition(); Console.WriteLine("\nThe definition is the same: {0}", miDef == mi);` 2.0.0.0 4.0.0.0 System.Runtime.InteropServices.ComVisible(true)
- Method
  4.0.0.0
  System.Int32 To be added. To be added. To be added.
- Method
  System.Type To be added. To be added. To be added. 1.0.5000.0
- Property
  System.Boolean

  Returns a value that indicates whether the current method is a generic method.

  if the current method is a generic method; otherwise .

  Use the property to determine whether a System.Reflection.MethodInfo object represents a generic method. Use the property to determine whether a object represents an open constructed method or a closed constructed method.

  The following table summarizes the invariant conditions for terms specific to generic methods. For other terms used in generic reflection, such as generic type parameter and generic type, see the property.

  Term
  Invariant
  generic method definition

  The property is .

  Defines a generic method. A constructed method is created by calling the method on a object that represents a generic method definition, and specifying an array of type arguments.

  can be called only on generic method definitions.

  Any generic method definition is a generic method, but the converse is not true.

  generic method

  The property is .

  Can be a generic method definition, an open constructed method, or a closed constructed method.

  open constructed method

  The property is .

  It is not possible to invoke an open constructed method.

  closed constructed method

  The property is .

  When examined recursively, the method has no unassigned generic parameters. The containing type has no generic type parameters, and none of the type arguments have generic type parameters.

  This property is read-only.

2.0.0.0
- Property
  System.Boolean

  Gets a value that indicates whether the current represents the definition of a generic method.

  if the object represents the definition of a generic method; otherwise .

  If the current represents a generic method definition, then:

  returns .
  For each object in the array returned by the method: The property returns ; the returns the current ; the property is the same as the position of the object in the array.

  Use the property to determine whether type arguments have been assigned to the type parameters of a generic method. If type arguments have been assigned, the property returns even if some of the type arguments are objects that represent type parameters of enclosing types. For example, consider the following C# code:

  `class C { T N<T,U>(T t, U u) {...} public V M<V>(V v) { return N<V,int>(v, 42); } }`

  The method body of contains a call to method , specifying the type parameter of and the type . The property returns for method .

  Although the open constructed method is not encountered when reflecting over class , it must be generated using .

  If a generic method definition includes generic parameters of the declaring type, there will be a generic method definition specific to each constructed type. For example, consider the following C# code:

  `class B<U,V> {} class C<T> { B<T,S> M<S>() {}}`

  In the constructed type , the generic method returns . In the open type , returns . In both cases, the property returns for the that represents .

  For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

  See the type for an example of the use of this property.

  This property is read-only.

  2.0.0.0
- Method
  System.Reflection.MethodInfo `System.ParamArray` To be added.

  Substitutes the elements of an array of types for the type parameters of the current generic method definition, and returns a object representing the resulting constructed method.

  A object that represents the constructed method formed by substituting the elements of for the type parameters of the current generic method definition.

  The method allows you to write code that assigns specific types to the type parameters of a generic method definition, thus creating a object that represents a particular constructed method. If the property of this object returns , you can use it to invoke the method or to create a delegate to invoke the method.

  Methods constructed with the method can be open; that is, some of their type arguments can be type parameters of enclosing generic types. You might use such open constructed methods when you generate dynamic assemblies. For example, consider the following C# code:

  `class C { T N<T,U>(T t, U u) {...} public V M<V>(V v) { return N<V,int>(v, 42); } }`

  The method body of M contains a call to method , specifying the type parameter of and the type . The property returns for method . The property returns , so method cannot be invoked.

  For a list of the invariant conditions for terms specific to generic methods, see the property. For a list of the invariant conditions for other terms used in generic reflection, see the property.

  The number of elements in is not the same as the number of type parameters of the current generic method definition.

  -or-

  An element of does not satisfy the constraints specified for the corresponding type parameter of the current generic method definition.

  is .

  -or-

  Any element of is .

  The current does not represent the definition of a generic method. (That is, returns ).

  The following code demonstrates the properties and methods of System.Reflection.MethodInfo that support the examination of generic methods. The example does the following:

  Defines a class that has a generic method.
  Creates a that represents the generic method.
  Displays properties of the generic method definition.
  Binds the to a type, and invokes it.
  Displays properties of the bound generic method.
  Retrieves the generic method definition from the bound method.
  `using System; using System.Reflection; // Define a class with a generic method. public class Example { public static void Generic<T>(T toDisplay) { Console.WriteLine("\nHere it is: {0}", toDisplay); } } public class Test { public static void Main() { Console.WriteLine("\n--- Examine a generic method."); // Create a Type object representing class Example, and // get a MethodInfo representing the generic method. // Type ex = Type.GetType("Example"); MethodInfo mi = ex.GetMethod("Generic"); DisplayGenericMethodInfo(mi); // Bind the type parameter of the Example method to // type int. // Type[] arguments = {typeof(int)}; MethodInfo miBound = mi.MakeGenericMethod(arguments); DisplayGenericMethodInfo(miBound); // Invoke the method. object[] args = {42}; miBound.Invoke(null, args); // Invoke the method normally. Example.Generic<int>(42); // Get the generic type definition from the closed method, // and show it's the same as the original definition. // MethodInfo miDef = miBound.GetGenericMethodDefinition(); Console.WriteLine("\nThe definition is the same: {0}", miDef == mi); } private static void DisplayGenericMethodInfo(MethodInfo mi) { Console.WriteLine("\n{0}", mi); Console.WriteLine("\tIs this a generic method definition? {0}", mi.IsGenericMethodDefinition); Console.WriteLine("\tDoes it have generic arguments? {0}", mi.IsGenericMethod); Console.WriteLine("\tDoes it have unbound generic parameters? {0}", mi.ContainsGenericParameters); // If this is a generic method, display its type arguments. // if (mi.IsGenericMethod) { Type[] typeArguments = mi.GetGenericArguments(); Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length); foreach (Type tParam in typeArguments) { // IsGenericParameter is true only for generic type // parameters. // if (tParam.IsGenericParameter) { Console.WriteLine("\t\t{0} (unbound - parameter position {1})", tParam, tParam.GenericParameterPosition); } else { Console.WriteLine("\t\t{0}", tParam); } } } else { Console.WriteLine("\tThis is not a generic method."); } } } /* This example produces the following output: --- Examine a generic method. Void Generic[T](T) Is this a generic method definition? True Does it have generic arguments? True Does it have unbound generic parameters? True List type arguments (1): T (unbound - parameter position 0) Void Generic[Int32](Int32) Is this a generic method definition? False Does it have generic arguments? True Does it have unbound generic parameters? False List type arguments (1): System.Int32 Here it is: 42 Here it is: 42 The definition is the same: True */` 2.0.0.0 4.0.0.0
- Property
  System.Reflection.MemberTypes To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Property
  System.Reflection.ParameterInfo To be added. To be added. To be added. 2.0.0.0 4.0.0.0
- Property
  System.Type

  Gets the type of the return value of the method reflected by the current instance.

  The of the return value of the method reflected by the current instance. This property is equal to the object representing if the return value of the method is .

  This property is read-only.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Property
  System.Reflection.ICustomAttributeProvider To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Void `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Void `` `` `` To be added. To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Void `` To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Method
  System.Void `` `` `` `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
0