CustomAttributeData.ConstructorArguments Property

 

Gets the list of positional arguments specified for the attribute instance represented by the CustomAttributeData object.

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

[<ComVisibleAttribute(true)>]
abstract ConstructorArguments : IList<CustomAttributeTypedArgument> with get
[<ComVisibleAttribute(true)>]
override ConstructorArguments : IList<CustomAttributeTypedArgument> with get

Property Value

Type: System.Collections.Generic.IList<CustomAttributeTypedArgument>

A collection of structures that represent the positional arguments specified for the custom attribute instance.

This method gets the positional arguments that were specified for the custom attribute instance without executing any of the custom attribute code. Thus, it can be used in the reflection-only context.

Use the NamedArguments method to get the named arguments specified for the attribute instance.

The following example defines a custom attribute with four constructors and four properties. Two of the properties are read-only, and are set by using the positional parameters of the constructors. The other two properties are read/write, and can be set only by using named arguments. One positional property is an array of strings, and one named property is an array of integers.

The attribute is applied to the assembly, to a type declared in the assembly, to a method of the type, and to a parameter of the method. Different constructors are used for these cases. When executed, the assembly loads itself into the reflection-only context and displays the custom attributes.

The attribute that is applied to the type demonstrates array properties, with both positional and named arguments.

The ConstructorArguments property is used in the ShowAttributeData method that displays custom attribute data. In this code example, this property is used to display the list of arguments passed to the constructor that initialized the attribute.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: