DateTimeOffset.Second Özellik

Tanım

Geçerli DateTimeOffset nesne tarafından temsil edilen saat saatinin ikinci bileşenini alır.

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

Özellik Değeri

Int32

Nesnenin DateTimeOffset 0 ile 59 arasında bir tamsayı değeri olarak ifade edilen ikinci bileşeni.

Örnekler

Aşağıdaki örnek, bir DateTimeOffset nesnenin ikinci bileşenini üç farklı şekilde görüntüler:

  • özelliğinin değerini Second alarak.

  • yöntemini "s" biçim tanımlayıcısı ile çağırarak ToString(String) .

  • yöntemini "ss" biçim tanımlayıcısı ile çağırarak ToString(String) .

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.

Açıklamalar

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

Yöntemini "s" veya "ss" özel biçim tanımlayıcılarıyla çağırarak nesnenin DateTimeOffset ToString ikinci bileşeninin dize gösterimini de oluşturabilirsiniz.

Şunlara uygulanır