Export (0) Print
Expand All

TypeBuilder.DefineProperty Method (String, PropertyAttributes, Type, Type[], Type[], Type[], Type[][], Type[][])

Adds a new property to the type, with the given name, property signature, and custom modifiers.

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

public PropertyBuilder DefineProperty (
	string name,
	PropertyAttributes attributes,
	Type returnType,
	Type[] returnTypeRequiredCustomModifiers,
	Type[] returnTypeOptionalCustomModifiers,
	Type[] parameterTypes,
	Type[][] parameterTypeRequiredCustomModifiers,
	Type[][] parameterTypeOptionalCustomModifiers
)
public PropertyBuilder DefineProperty (
	String name, 
	PropertyAttributes attributes, 
	Type returnType, 
	Type[] returnTypeRequiredCustomModifiers, 
	Type[] returnTypeOptionalCustomModifiers, 
	Type[] parameterTypes, 
	Type[][] parameterTypeRequiredCustomModifiers, 
	Type[][] parameterTypeOptionalCustomModifiers
)
public function DefineProperty (
	name : String, 
	attributes : PropertyAttributes, 
	returnType : Type, 
	returnTypeRequiredCustomModifiers : Type[], 
	returnTypeOptionalCustomModifiers : Type[], 
	parameterTypes : Type[], 
	parameterTypeRequiredCustomModifiers : Type[][], 
	parameterTypeOptionalCustomModifiers : Type[][]
) : PropertyBuilder
Not applicable.

Parameters

name

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

attributes

The attributes of the property.

returnType

The return type of the property.

returnTypeRequiredCustomModifiers

An array of types representing the required custom modifiers, such as IsConst, for the return type of the property. If the return type has no required custom modifiers, specify a null reference (Nothing in Visual Basic).

returnTypeOptionalCustomModifiers

An array of types representing the optional custom modifiers, such as IsConst, for the return type of the property. If the return type has no optional custom modifiers, specify a null reference (Nothing in Visual Basic).

parameterTypes

The types of the parameters of the property.

parameterTypeRequiredCustomModifiers

An array of arrays of types. Each array of types represents the required custom modifiers for the corresponding parameter, such as IsConst. If a particular parameter has no required custom modifiers, specify a null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have required custom modifiers, specify a null reference (Nothing in Visual Basic) instead of an array of arrays.

parameterTypeOptionalCustomModifiers

An array of arrays of types. Each array of types represents the optional custom modifiers for the corresponding parameter, such as IsConst. If a particular parameter has no optional custom modifiers, specify a null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have optional custom modifiers, specify a null reference (Nothing in Visual Basic) instead of an array of arrays.

Return Value

The defined property.

Exception typeCondition

ArgumentException

The length of name is zero.

ArgumentNullException

name is a null reference (Nothing in Visual Basic)

-or-

Any of the elements of the parameterTypes array is a null reference (Nothing in Visual Basic)

InvalidOperationException

The type was previously created using CreateType.

This overload is provided for designers of managed compilers.

NoteNote:

For more information on custom modifiers, see the ECMA Partition II Metadata documentation. Partition II documentation is available online at http://msdn.microsoft.com/net/ecma/ and http://www.ecma-international.org/publications/standards/Ecma-335.htm.

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:
© 2014 Microsoft