Core.Option<'T> Union (F#)

Specifies the type of optional values, which you use when there might or might not be a value.

Namespace/Module Path: Microsoft.FSharp.Core

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

[<DefaultAugmentation(false)>]
[<StructuralEquality>]
[<StructuralComparison>]
type Option<'T> =
| None
| Some of 'T
 with
  interface IStructuralEquatable
  interface IComparable
  interface IComparable
  interface IStructuralComparable
  static member Some : 'T -> 'T option
  member this.IsNone :  bool
  member this.IsSome :  bool
  static member None :  'T option
  member this.Value :  'T
 end

Use the constructors Some and None to create values of this type. Use the values in the Option module to manipulate values of this type, or pattern match against the values directly. None values appear as the value null to other .NET Framework languages. Instance methods of this type appear as static methods to other .NET Framework languages because of the use of null as a value representation.

For an overview of options, see Options (F#).

This type is named FSharpOption in compiled assemblies. If you are accessing the type from a language other than F#, or through reflection, use this name.

Member

Description

IsNone

Returns true if the option is a None value.

IsSome

Returns true if the option is a Some value.

Value

Gets the value of a Some option. A NullReferenceException is raised if the option is None.

Member

Description

None

Creates an option value that is a None value.

Some

Creates an option value that is a Some value.

Case

Description

None

Specifies that there is no value.

Some of 'T

Contains the value, when there is a value.

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft