Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TypeBuilder.DefineMethod Method (String, MethodAttributes, CallingConventions, Type, 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 MethodBuilder DefineMethod(
	string name,
	MethodAttributes attributes,
	CallingConventions callingConvention,
	Type returnType,
	Type[] parameterTypes
)

Parameters

name
Type: System.String
The name of the method. name cannot contain embedded nulls.
attributes
Type: System.Reflection.MethodAttributes
The attributes of the method.
callingConvention
Type: System.Reflection.CallingConventions
The calling convention of the method.
returnType
Type: System.Type
The return type of the method.
parameterTypes
Type: System.Type[]
The types of the parameters of the method.

Return Value

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

ExceptionCondition
ArgumentException

The length of name is zero.

-or-

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

ArgumentNullException

name is null.

InvalidOperationException

The type was previously created using CreateType.

-or-

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

Silverlight

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft