C# 程式顯示某月中天數
使用 DaysInMonth 來顯示某月中天數。
將年和月作為 DaysInMonth() 方法的引數新增進去——
DateTime.DaysInMonth(2018, 8);
以下是一個示例——
示例
using System;
using System.Collections.Generic;
using System.Linq;
public class Demo {
public static void Main() {
Console.WriteLine("Today = {0}", DateTime.Today);
int num_days = DateTime.DaysInMonth(2018, 8);
Console.WriteLine("Days in August: "+num_days);
}
}輸出
Today = 9/4/2018 12:00:00 AM Days in August: 31
廣告
資料結構
網路技術
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP