महीने में दिनों की संख्या प्रदर्शित करने के लिए 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