Value Property
Collapse the table of content
Expand the table of content

CustomAttributeTypedArgument.Value Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the value of the argument for a simple argument or for an element of an array argument; gets a collection of values for an array argument.

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

'Declaration
Public ReadOnly Property Value As Object

Property Value

Type: System.Object
An object that represents the value of the argument or element, or a generic ReadOnlyCollection(Of T) of CustomAttributeTypedArgument objects that represent the values of an array-type argument.

If the CustomAttributeTypedArgument represents an array argument, this property returns a ReadOnlyCollection<CustomAttributeTypedArgument> (ReadOnlyCollection(Of CustomAttributeTypedArgument) in Visual Basic). Each element of the collection represents the corresponding element of the array argument.

The type of the value can be obtained by using the ArgumentType property. ArgumentType gets the actual type of the value returned by the Value property for simple arguments or for elements of array arguments. It returns the array type for array arguments.

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 Value property is used in the ShowValueOrArray method that displays custom attribute data, to display the values of attributes.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft