Export (0) Print
Expand All

TypeBuilder.DefineMethod Method (String, MethodAttributes, CallingConventions)

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

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

public MethodBuilder DefineMethod (
	string name,
	MethodAttributes attributes,
	CallingConventions callingConvention
)
public MethodBuilder DefineMethod (
	String name, 
	MethodAttributes attributes, 
	CallingConventions callingConvention
)
public function DefineMethod (
	name : String, 
	attributes : MethodAttributes, 
	callingConvention : CallingConventions
) : MethodBuilder
Not applicable.

Parameters

name

The name of the method. name cannot contain embedded nulls.

attributes

The attributes of the method.

callingConvention

The calling convention of the method.

Return Value

A MethodBuilder representing the newly defined method.

Exception typeCondition

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 a null reference (Nothing in Visual Basic).

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.

Use this method overload when you do not know the method signature at the time you define the method. For example, the parameter types and return type of a generic method might be specified by the method's generic type parameters, which must be defined after the method has been added to the type. The parameters and return type of the method can be set later using the MethodBuilder.SetSignature method.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft