Table of Contents

Class KeyAttribute

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

Specifies an ordinal key that may be used when the object serializes its properties as an array of values instead of a map of property names to values.

[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class KeyAttribute : Attribute
Inheritance
KeyAttribute
Inherited Members

Remarks

Once this key is applied to any field or property of a type, it must be applied to all fields and properties of that type that are candidates for serialization. Reassigning a key to a different member of the same type is an unversioned breaking change in the serialization schema and should be avoided when reading or writing across versions is supported. Unassigned indexes in the array will be left as nil during serialization and ignored during deserialization.

Constructors

KeyAttribute(int)

Initializes a new instance of the KeyAttribute class.

public KeyAttribute(int index)

Parameters

index int

The index into the array where the value of the annotated member will be stored.

Properties

Index

Gets the array index where the value of the annotated member will be stored.

public int Index { get; }

Property Value

int