Share via


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

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Function DefineProperty ( _
    name As String, _
    attributes As PropertyAttributes, _
    returnType As Type, _
    returnTypeRequiredCustomModifiers As Type(), _
    returnTypeOptionalCustomModifiers As Type(), _
    parameterTypes As Type(), _
    parameterTypeRequiredCustomModifiers As Type()(), _
    parameterTypeOptionalCustomModifiers As Type()() _
) As PropertyBuilder
public PropertyBuilder DefineProperty(
    string name,
    PropertyAttributes attributes,
    Type returnType,
    Type[] returnTypeRequiredCustomModifiers,
    Type[] returnTypeOptionalCustomModifiers,
    Type[] parameterTypes,
    Type[][] parameterTypeRequiredCustomModifiers,
    Type[][] parameterTypeOptionalCustomModifiers
)

Parameters

  • name
    Type: System.String
    The name of the property. name cannot contain embedded nulls.
  • returnType
    Type: System.Type
    The return type of the property.
  • returnTypeRequiredCustomModifiers
    Type: array<System.Type[]
    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 nulla null reference (Nothing in Visual Basic).
  • returnTypeOptionalCustomModifiers
    Type: array<System.Type[]
    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 nulla null reference (Nothing in Visual Basic).
  • parameterTypes
    Type: array<System.Type[]
    The types of the parameters of the property.
  • parameterTypeRequiredCustomModifiers
    Type: array<array<System.Type[][]
    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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have required custom modifiers, specify nulla null reference (Nothing in Visual Basic) instead of an array of arrays.
  • parameterTypeOptionalCustomModifiers
    Type: array<array<System.Type[][]
    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 nulla null reference (Nothing in Visual Basic) instead of an array of types. If none of the parameters have optional custom modifiers, specify nulla null reference (Nothing in Visual Basic) instead of an array of arrays.

Return Value

Type: System.Reflection.Emit.PropertyBuilder
The defined property.

Exceptions

Exception Condition
ArgumentException

The length of name is zero.

ArgumentNullException

name is nulla null reference (Nothing in Visual Basic)

-or-

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

InvalidOperationException

The type was previously created using CreateType.

Remarks

This overload is provided for designers of managed compilers.

NoteNote:

For more information about custom modifiers, see the ECMA Partition II Metadata documentation. The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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