c#如何獲取當(dāng)前時(shí)間

c#
小億
98
2024-01-16 15:17:47
欄目: 編程語言

在C#中,可以使用DateTime.Now屬性來獲取當(dāng)前日期和時(shí)間。

以下是一個(gè)示例代碼:

using System;

class Program
{
    static void Main()
    {
        DateTime now = DateTime.Now;
        Console.WriteLine("當(dāng)前時(shí)間:" + now);
    }
}

運(yùn)行上述代碼,將會(huì)輸出當(dāng)前的日期和時(shí)間。

0