Share via


FSharpValue.GetUnionFields Method (F#)

Identify the union case and its fields for an object.

Namespace/Module Path: Microsoft.FSharp.Reflection

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
static member GetUnionFields : obj * Type * ?BindingFlags -> UnionCaseInfo * obj []

// Usage:
FSharpValue.GetUnionFields (value, unionType)
FSharpValue.GetUnionFields (value, unionType, bindingFlags = bindingFlags)

Parameters

  • value
    Type: obj

    The input union case.

  • unionType
    Type: Type

    The union type containing the value.

  • bindingFlags
    Type: BindingFlags

    Optional binding flags.

Exceptions

Exception

Condition

ArgumentException

Thrown when the input type is not a union case value.

Return Value

The description of the union case (as a UnionCaseInfoobject) and its fields.

Remarks

If the type is not given, then the runtime type of the input object is used to identify the relevant union type. The type should always be given if the input object may be null. For example, option values may be represented using the null.

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Reflection.FSharpValue Class (F#)

Microsoft.FSharp.Reflection Namespace (F#)