Bagikan melalui


DateTimeOffset.Millisecond Properti

Definisi

Mendapatkan komponen milidetik dari waktu yang diwakili oleh objek saat ini DateTimeOffset .

public:
 property int Millisecond { int get(); };
public int Millisecond { get; }
member this.Millisecond : int
Public ReadOnly Property Millisecond As Integer

Nilai Properti

Komponen milidetik dari objek saat ini DateTimeOffset , dinyatakan sebagai bilangan bulat antara 0 dan 999.

Contoh

Contoh berikut menampilkan jumlah milidetik DateTimeOffset objek dengan menggunakan penentu format kustom dan dengan langsung mengakses Millisecond properti .

DateTimeOffset date1 = new DateTimeOffset(2008, 3, 5, 5, 45, 35, 649,
                                new TimeSpan(-7, 0, 0));
Console.WriteLine("Milliseconds value of {0} is {1}.",
                  date1.ToString("MM/dd/yyyy hh:mm:ss.fff"),
                  date1.Millisecond);
// The example produces the following output:
//
// Milliseconds value of 03/05/2008 05:45:35.649 is 649.
let date1 = DateTimeOffset(2008, 3, 5, 5, 45, 35, 649, TimeSpan(-7, 0, 0))
printfn $"""Milliseconds value of {date1.ToString "MM/dd/yyyy hh:mm:ss.fff"} is {date1.Millisecond}."""
                
// The example produces the following output:
//
// Milliseconds value of 03/05/2008 05:45:35.649 is 649.
Dim date1 As New DateTimeOffset(2008, 3, 5, 5, 45, 35, 649, _
                                New TimeSpan(-7, 0, 0))
Console.WriteLine("Milliseconds value of {0} is {1}.", _
                  date1.ToString("MM/dd/yyyy hh:mm:ss.fff"), _
                  date1.Millisecond)
' The example produces the following output:
'
' Milliseconds value of 03/05/2008 05:45:35.649 is 649.

Keterangan

Anda juga dapat membuat representasi string komponen DateTimeOffset milidetik objek dengan memanggil ToString metode dengan penentu format kustom "fff".

Jika Anda mengandalkan properti seperti Now atau UtcNow untuk melacak jumlah milidetik yang berlalu secara akurat, presisi komponen milidetik waktu tergantung pada resolusi jam sistem. Pada Windows NT 3.5 dan yang lebih baru, dan sistem operasi Windows Vista, resolusi jam sekitar 10-15 milidetik.

Berlaku untuk