DateTime.Deconstruct 方法

定义

重载

Deconstruct(DateOnly, TimeOnly)

Source:
DateTime.cs
Source:
DateTime.cs

通过 DateOnlyTimeOnly解构此DateTime实例。

C#
public void Deconstruct(out DateOnly date, out TimeOnly time);

参数

date
DateOnly

此方法返回时, 表示 DateOnlyDateTime 实例的值。

time
TimeOnly

此方法返回时, 表示 TimeOnlyDateTime 实例的值。

适用于

.NET 10 和其他版本
产品 版本
.NET 8, 9, 10

Deconstruct(Int32, Int32, Int32)

Source:
DateTime.cs
Source:
DateTime.cs

YearMonthDay解构此DateOnly实例。

C#
public void Deconstruct(out int year, out int month, out int day);

参数

year
Int32

此方法返回时, 表示 YearDateTime 实例的值。

month
Int32

此方法返回时, 表示 MonthDateTime 实例的值。

day
Int32

此方法返回时, 表示 DayDateTime 实例的值。

适用于

.NET 10 和其他版本
产品 版本
.NET 8, 9, 10