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) Requires permission to reflect non-public members of a type in loaded assemblies. See .

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.

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

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added.

  Initializes a new instance of the class.

  0
- Property
  System.Boolean

  if the contains unassigned generic type parameters; otherwise .

  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. Making this recursive determination can be difficult. For convenience, and to reduce the chance of error, the property provides a standard way to distinguish between closed constructed methods, which can be invoked, and open constructed methods, which cannot. If the property returns true, the method cannot be invoked.

  The property searches recursively for type parameters. For example, it returns true for any method in an open type A<T> (A(Of T) in Visual Basic), 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.

  Gets a value indicating whether a generic method contains unassigned generic type parameters.

  2.0.0.0
- Method
  4.0.0.0
  System.Delegate `` To be added.

  Creates a delegate of the specified type from this method.

  The delegate for this method.

  The type of the delegate to create.
- Method
  4.0.0.0
  System.Delegate `` `` To be added.

  Creates a delegate of the specified type with the specified target from this method.

  The delegate for this method.

  The type of the delegate to create. The object targeted by the delegate.
- Method
  4.0.0.0
  System.Boolean `` To be added.

  Returns a value that indicates whether this instance is equal to a specified object.

  true if equals the type and value of this instance; otherwise, false.

  An object to compare with this instance, or null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Reflection.MethodInfo

  GetBaseDefinition returns the first definition of the specified method in the class hierarchy.

  If the method is declared on an interface, GetBaseDefinition returns the method.

  If the method is defined in a base class, then GetBaseDefinition works as follows:

  If a given method overrides a virtual definition in the base class, the virtual definition is returned.

  If a given method is specified with the new keyword (as in newslot as described in Common Type System), the given method is returned.

  If the method is not defined in the type of the object on which GetBaseDefinition is called, the method definition highest in the class hierarchy is returned.

  To get the GetBaseDefinition method, first get the class . From the Type, get the . From the MethodInfo, get the GetBaseDefinition.

  When overridden in a derived class, returns the MethodInfo object for the method on the direct or indirect base class in which the method represented by this instance was first declared.

  A MethodInfo object for the first implementation of this method.

  0
- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Type[]

  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."); } }`

  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 false), 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 true) 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 demonstration of this scenario, see the code example for the property.

  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.

  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.

- Method
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Reflection.MethodInfo 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);`

  A generic method definition is a template from which methods can be constructed. For example, from the generic method definition T M<T>(T t) (expressed in C# syntax; Function M(Of T)(ByVal tVal As T) As T in Visual Basic) you can construct and invoke the method int M<int>(int t) (Function M(Of Integer)(ByVal tVal As Integer) As Integer in Visual Basic). 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#, Visual Basic, and C++ code:

  `class B<U,V> {} class C<T> { public B<T,S> M<S>() {...}} Class B(Of U, V) End Class Class C(Of T) Public Function M(Of S)() As B(Of T, S) ... End Function End Class generic <typename U, typename V> ref class B {}; generic <typename T> ref class C { public: generic <typename S> B<T,S>^ M() {...}; };`

  In the constructed type C<int> (C(Of Integer) in Visual Basic), the generic method M returns B<int, S>. In the open type C<T>, M returns B<T, S>. In both cases, the property returns true for the that represents M, 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.

  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.

- Method
  4.0.0.0
  System.Int32 To be added.

  Returns the hash code for this instance.

  A 32-bit signed integer hash code.

- Method
  System.Type To be added. To be added. To be added. 1.0.5000.0
- Property
  System.Boolean if the current method is a generic method; otherwise .

  Use the property to determine whether a 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 true.

  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 true.

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

  open constructed method

  The property is true.

  It is not possible to invoke an open constructed method.

  closed constructed method

  The property is false.

  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.

  The method can be invoked.

  Gets a value indicating whether the current method is a generic method.

  2.0.0.0
- Property
  System.Boolean if the object represents the definition of a generic method; otherwise .

  If the current represents a generic method definition, then:

  returns true.

  For each object in the array returned by the method:

  The property returns true.

  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 false even if some of the type arguments are objects that represent type parameters of enclosing types. For example, consider the following C#, Visual Basic, and C++ code:

  `class C { T N<T,U>(T t, U u) {...} public V M<V>(V v) { return N<V,int>(v, 42); } } Class C Public Function N(Of T,U)(ByVal ta As T, ByVal ua As U) As T ... End Function Public Function M(Of V)(ByVal va As V ) As V Return N(Of V, Integer)(va, 42) End Function End Class ref class C { private: generic <typename T, typename U> T N(T t, U u) {...} public: generic <typename V> V M(V v) { return N<V, int>(v, 42); } };`

  The method body of M contains a call to method N, specifying the type parameter of M and the type . The property returns false for method N<V,int>.

  Although the open constructed method N<V,int> is not encountered when reflecting over class C, it must be generated using in order to emit C as a dynamic class.

  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# and Visual Basic code:

  `class B<U,V> {} class C<T> { public B<T,S> M<S>() {...}} Class B(Of U, V) End Class Class C(Of T) Public Function M(Of S)() As B(Of T, S) ... End Function End Class generic <typename U, typename V> ref class B {}; generic <typename T> ref class C { public: generic <typename S> B<T,S>^ M() {...}; };`

  In the constructed type C<int> (C(Of Integer) in Visual Basic), the generic method M returns B<int, S>. In the open type C<T>, M returns B<T, S>. In both cases, the property returns true for the that represents M.

  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.

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

  2.0.0.0
- Method
  2.0.0.0
  4.0.0.0
  System.Reflection.MethodInfo `System.ParamArray`

  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 */`

  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 true, 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#, Visual Basic, and C++ code.

  `class C { T N<T,U>(T t, U u) {...} public V M<V>(V v) { return N<V,int>(v, 42); } } Class C Public Function N(Of T,U)(ByVal ta As T, ByVal ua As U) As T ... End Function Public Function M(Of V)(ByVal va As V ) As V Return N(Of V, Integer)(va, 42) End Function End Class ref class C { private: generic <typename T, typename U> T N(T t, U u) {...} public: generic <typename V> V M(V v) { return N<V, int>(v, 42); } };`

  The method body of M contains a call to method N, specifying the type parameter of M and the type . The property returns false for method N<V,int>. The property returns true, so method N<V,int> 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.

  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.

  An array of types to be substituted for the type parameters of the current generic method definition.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Reflection.MemberTypes To be added.

  This property overrides . Therefore, when you examine a set of objects — for example, the array returned by — the property returns only when a given member is a method.

  To get the MemberType property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the MemberType.

  Gets a value indicating that this member is a method.

- Method
  4.0.0.0
  System.Boolean `` `` To be added.

  Indicates whether two objects are equal.

  true if is equal to ; otherwise, false.

  The first object to compare. The second object to compare.
- Method
  4.0.0.0
  System.Boolean `` `` To be added.

  Indicates whether two objects are not equal.

  true if is not equal to ; otherwise, false.

  The first object to compare. The second object to compare.
- Property
  2.0.0.0
  4.0.0.0
  System.Reflection.ParameterInfo To be added.

  Compiler designers can use the object returned by this property to discover whether custom modifiers, such as , have been applied to the return type.

  Gets a object that contains information about the return type of the method, such as whether the return type has custom modifiers.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Type

  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 .

  To get the return type property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the ReturnType.

  Gets the return type of this method.

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

  Gets the custom attributes for the return type.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Type To be added.

  Provides access to the method from COM.

  A object representing the type.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  This method is for access to managed classes from unmanaged code, and should not be called from managed code. For more information about IDispatch::GetTypeInfo, see the MSDN Library.

  Retrieves the type information for an object, which can be used to get the type information for an interface.

  The type information to return. The locale identifier for the type information. Receives a pointer to the requested type information object.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  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.
0