Udostępnij za pośrednictwem


DateTimeOffset.Second Właściwość

Definicja

Pobiera drugi składnik czasu zegara reprezentowanego przez bieżący DateTimeOffset obiekt.

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

Wartość właściwości

Drugi składnik DateTimeOffset obiektu, wyrażony jako wartość całkowita z zakresu od 0 do 59.

Przykłady

Poniższy przykład przedstawia drugi składnik DateTimeOffset obiektu na trzy różne sposoby:

  • Pobieranie wartości właściwości Second.

  • Wywołując metodę ToString(String) za pomocą specyfikatora formatu "s".

  • Wywołując metodę ToString(String) za pomocą specyfikatora formatu "ss".

DateTimeOffset theTime = new DateTimeOffset(2008, 6, 12, 21, 16, 32,
                             DateTimeOffset.Now.Offset);
Console.WriteLine("The second component of {0} is {1}.",
                  theTime, theTime.Second);

Console.WriteLine("The second component of {0} is{1}.",
                  theTime, theTime.ToString(" s"));

Console.WriteLine("The second component of {0} is {1}.",
                  theTime, theTime.ToString("ss"));
// The example produces the following output:
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
let theTime = DateTimeOffset(2008, 6, 12, 21, 16, 32, DateTimeOffset.Now.Offset)
printfn $"The second component of {theTime} is {theTime.Second}."

printfn $"""The second component of {theTime} is{theTime.ToString " s"}."""

printfn $"The second component of {theTime} is {theTime:ss}."

// The example produces the following output:
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
Dim theTime As New DateTimeOffset(#6/12/2008 9:16:32PM#, _
                                       DateTimeOffset.Now.Offset)
Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.Second)

Console.WriteLine("The second component of {0} is{1}.", _
                  theTime, theTime.ToString(" s"))

Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.ToString("ss"))
' The example produces the following output:
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.

Uwagi

Właściwość Second nie ma wpływu na wartość Offset właściwości.

Można również utworzyć ciąg reprezentujący DateTimeOffset drugi składnik obiektu, wywołując ToString metodę za pomocą specyfikatorów formatu niestandardowego "s" lub "ss".

Dotyczy