Export (0) Print
Expand All

DateTimeOffset Implicit Conversion (DateTime to DateTimeOffset)

Defines an implicit conversion of a DateTime object to a DateTimeOffset object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

F# does not support the declaration of new casting operators.

Parameters

dateTime
Type: System.DateTime
The object to convert.

Return Value

Type: System.DateTimeOffset
The converted object.

ExceptionCondition
ArgumentOutOfRangeException

The Coordinated Universal Time (UTC) date and time that results from applying the offset is earlier than MinValue.

-or-

The UTC date and time that results from applying the offset is later than MaxValue.

The Implicit method enables the compiler to automatically convert a DateTime object to a DateTimeOffset object without an explicit casting operator (in C#) or a call to a conversion function (in Visual Basic). It defines a widening conversion that does not involve data loss and does not throw an OverflowException. The Implicit method makes code such as the following possible:

No code example is currently available or this language may not be supported.

This method is equivalent to the DateTimeOffset constructor. The offset of the resulting DateTimeOffset object depends on the value of the DateTime.Kind property of the dateTime parameter:

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft