DateTimeOffset.TimeOfDay Özellik

Tanım

Geçerli DateTimeOffset nesne için günün saatini alır.

public:
 property TimeSpan TimeOfDay { TimeSpan get(); };
public TimeSpan TimeOfDay { get; }
member this.TimeOfDay : TimeSpan
Public ReadOnly Property TimeOfDay As TimeSpan

Özellik Değeri

TimeSpan

Gece yarısından bu yana geçen geçerli tarihin zaman aralığı.

Örnekler

Aşağıdaki örnek, saati ayıklamak ve konsolda görüntülemek için özelliğini kullanır TimeOfDay .

DateTimeOffset currentDate = new DateTimeOffset(2008, 5, 10, 5, 32, 16,
                                      DateTimeOffset.Now.Offset);
TimeSpan currentTime = currentDate.TimeOfDay;
Console.WriteLine("The current time is {0}.", currentTime.ToString());
// The example produces the following output:
//       The current time is 05:32:16.
let currentDate = DateTimeOffset(2008, 5, 10, 5, 32, 16, DateTimeOffset.Now.Offset)
let currentTime = currentDate.TimeOfDay
printfn $"The current time is {currentTime}."
// The example produces the following output:
//       The current time is 05:32:16.
Dim currentDate As New DateTimeOffset(#5/10/2008 5:32:16AM#, _
                                      DateTimeOffset.Now.Offset) 
Dim currentTime As TimeSpan = currentDate.TimeOfDay
Console.WriteLine("The current time is {0}.", currentTime.ToString())
' The example produces the following output: 
'       The current time is 05:32:16.

Açıklamalar

TimeOfDay özelliği, özelliğin değerinden Offset etkilenmez.

özelliği, TimeOfDay bir DateTimeOffset nesnenin saat bileşenini nesne TimeSpan biçiminde döndürür. Özelliğine DateTime.TimeOfDay eşdeğerdir.

Şunlara uygulanır