ChoiceAttribute Class

Maps a member of an enumeration to a String choice value for a Choice or MultiChoice type field on a Microsoft SharePoint Foundation list.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.SharePoint.Linq.DataAttribute
      Microsoft.SharePoint.Linq.ChoiceAttribute

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Field, AllowMultiple := False)> _
Public NotInheritable Class ChoiceAttribute _
    Inherits DataAttribute
'Usage
Dim instance As ChoiceAttribute
[AttributeUsageAttribute(AttributeTargets.Field, AllowMultiple = false)]
public sealed class ChoiceAttribute : DataAttribute

Remarks

This attribute is used to decorate the members of an enum class.

The inherited members of this class are not applicable and should be ignored.

Examples

The following is an example of this attribute in use:

public enum TaskStatusChoices : int {

Invalid,

None,

[Choice(Value="Not Started")]
NotStarted,

[Choice(Value="In Progress")]
InProgress,

[Choice(Value="Completed")]
Completed,

[Choice(Value="Deferred")]
Deferred,

[Choice(Value="Waiting on someone else")]
WaitingOnSomeoneElse,
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ChoiceAttribute Members

Microsoft.SharePoint.Linq Namespace