Learn how to find number of days in a given month in asp.net using c#

In this tutorial you will learn how to find number of days in a given month in asp.net using c#. It's quite easy. DateTime class has built-in function DaysInMonth(year,month) that takes two parameters, first one is Year, second one is month and then return the number of days in that given month. Let’s have a look over example given below

Find number of days in a given month in asp.net using c#

Number-of-days-in-month.aspx.cs
int totalDays = DateTime.DaysInMonth(2007, 6); //Pass valid year and month

Now totalDays variable will have total number of days in a given month. I hope it will be great helpful for you.


Happy Coding, Keep Coding.

0 comments: