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