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 []
static member GetUnionFields : obj * Type * ?bool -> UnionCaseInfo * obj []
// Usage:
FSharpValue.GetUnionFields (value, unionType)
FSharpValue.GetUnionFields (value, unionType, bindingFlags = bindingFlags)
open FSharpReflectionExtensions
FSharpValue.GetUnionFields (value, unionType, allowAccessToPrivateRepresentation = false)
Parameters
value
Type: objThe input union case.
unionType
Type: TypeThe union type containing the value.
bindingFlags
Type: BindingFlagsOptional binding flags.
allowAccessToPrivateRepresentation
Type: boolOptional flag that denotes accessibility of the private representation.
Exceptions
Exception |
Condition |
---|---|
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 8, Windows 7, Windows Server 2012, Windows Server 2008 R2
Version Information
F# Core Library Versions
Supported in: 2.0, 4.0, Portable