DateTimeOffset Implicit Conversion (DateTime to DateTimeOffset)
Defines an implicit conversion of a DateTime object to a DateTimeOffset object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- dateTime
-
Type:
System::DateTime
The object to convert.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException |
The Implicit(DateTime to DateTimeOffset) 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(DateTime to DateTimeOffset) method makes code such as the following possible:
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:
If the value of the DateTime::Kind property is DateTimeKind::Utc, the date and time of the DateTimeOffset object is set equal to dateTime, and its Offset property is set equal to 0.
If the value of the DateTime::Kind property is DateTimeKind::Local or DateTimeKind::Unspecified, the date and time of the DateTimeOffset object is set equal to dateTime, and its Offset property is set equal to the offset of the local system's current time zone.
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1