TypeBuilder.DefineMethod Method (String, MethodAttributes, CallingConventions, Type, array<Type[])

Adds a new method to the type, with the specified name, method attributes, calling convention, and method signature.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)


Public Function DefineMethod ( _
    name As String, _
    attributes As MethodAttributes, _
    callingConvention As CallingConventions, _
    returnType As Type, _
    parameterTypes As Type() _
) As MethodBuilder
public MethodBuilder DefineMethod(
    string name,
    MethodAttributes attributes,
    CallingConventions callingConvention,
    Type returnType,
    Type[] parameterTypes


  • name
    Type: System.String
    The name of the method. name cannot contain embedded nulls.
  • returnType
    Type: System.Type
    The return type of the method.
  • parameterTypes
    Type: array<System.Type[]
    The types of the parameters of the method.

Return Value

Type: System.Reflection.Emit.MethodBuilder
The defined method.


Exception Condition

The length of name is zero.


The type of the parent of this method is an interface, and this method is not virtual (Overridable in Visual Basic).


name is nulla null reference (Nothing in Visual Basic).


The type was previously created using CreateType.


For the current dynamic type, the IsGenericType property is true, but the IsGenericTypeDefinition property is false.

Version Information


Supported in: 5, 4, 3


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.