Table of contents
TOC
Collapse the table of content
Expand the table of content

Core.DefaultValueAttribute Class (F#)

Den Delimarsky|Last Updated: 7/4/2016
|
1 Contributor

Adding this attribute to a field declaration means that the field is not initialized. During type checking a constraint is asserted that the field type supports null. If the Check value is false then the constraint is not asserted.

Namespace/Module Path: Microsoft.FSharp.Core

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

Syntax

[<AttributeUsage(AttributeTargets.Field, AllowMultiple = false)>]
[<Sealed>]
type DefaultValueAttribute =
class
new DefaultValueAttribute : bool -> DefaultValueAttribute
new DefaultValueAttribute : unit -> DefaultValueAttribute
member this.Check :  bool
end

Remarks

This attribute is intended to be used on explicit fields in classes and structures. It shouldn't be used on records. For more information, see Records (F#) and Explicit Fields: The val Keyword (F#).

The .NET Framework namespace System.ComponentModel defines an attribute that has the same name: System.ComponentModel.DefaultValueAttribute. Therefore, you must fully qualify the F# attribute if you open the System.ComponentModel namespace.

You can also use the short form of the name, DefaultValue.

Constructors

MemberDescription
newCreates an instance of the attribute

Instance Members

MemberDescription
CheckIndicates if a constraint is asserted that the field type supports '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

See Also

Microsoft.FSharp.Core Namespace (F#)

© 2016 Microsoft