Partager via


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

Remarks

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.

Instance Members

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.

Static Members

Member

Description

None

Creates an option value that is a None value.

Some

Creates an option value that is a Some value.

Union Cases

Case

Description

None

Specifies that there is no value.

Some of 'T

Contains the value, when there is a value.

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

See Also

Reference

Microsoft.FSharp.Core Namespace (F#)