
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Program to display the number of days in a month
Use the DaysInMonth to display the number of days in a month.
Add the year and month as a parameter for the DaysInMonth() method −
DateTime.DaysInMonth(2018, 8);
The following is an example −
Example
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); } }
Output
Today = 9/4/2018 12:00:00 AM Days in August: 31
- Related Articles
- Number of days in a month in Python
- How to find out number of days in a month in MySQL?
- How to get a number of days in a specified month using JavaScript?
- How to find the number of days in a month of a particular year in Java?
- How to calculate number of days in a month or a year in Excel?
- C program to convert days into months and number of days
- C++ Program to Display Factors of a Number
- C++ Program to calculate the number of odd days in given number of years
- How to calculate the number of working days left in the current month in Excel?
- Program to convert given number of days in terms of Years, Weeks and Days in C
- Display the month number with SimpleDateFormat(“M”) in Java
- C# Program to display the Factors of the Entered Number
- C# program to display factors of entered number
- Display month by name and number in Java
- Java Program to display previous month from GregorianCalendar

Advertisements