In this article, we will learn how to check if the selected date is the last day of the month or not using c#.
Here is the code to check if the selected date is the last day of the month or not.
using System;
namespace CheckLastDayofMonth
{
class Program
{
static void Main(string[] args)
{
// Output your dates
DateTime dt = new DateTime(2015, 3, 31);
//DateTime dt = DateTime.Now; //if you want check current date, use DateTime.Now
// Is this the last day of the month
bool isLastDayOfMonth = (dt.Day == DateTime.DaysInMonth(dt.Year, dt.Month));
Console.WriteLine(isLastDayOfMonth);
Console.ReadKey();
}
}
}
true
I hope this article will help you to understand how to check if the selected date is the last day of the month or not using c#.
Share your valuable feedback and help us to improve. If you find anything incorrect, or you want to share more information about the topic discussed above. please post your comment at the bottom of this article. Thank you!
Comments