Code for getting the Current month's first date and last date using Tuple in C#

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 277
The below code will do so

using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var dt = GetCurrentDate();
var stDT = dt.Item1;
var etDT = dt.Item2;
}

private static Tuple<DateTime,DateTime> GetCurrentDate()
{
DateTime date = DateTime.Now;
var firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
return Tuple.Create(firstDayOfMonth, lastDayOfMonth);
}
}
}

Comments or Responses

Login to post response