compute months c#
public static int GetMonthDifference(DateTime startDate, DateTime endDate)
{
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
compute months c#
public static int GetMonthDifference(DateTime startDate, DateTime endDate)
{
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
How to get an array of months in c#
var months = new string[12];
for (var month = 1; month <= 12; month++)
{
var firstDay = new DateTime(DateTime.Now.Year, month, 1);
var name = firstDay.ToString("MMMM", CultureInfo.CreateSpecificCulture("en"));
months[month - 1] = name;
}
foreach (var month in months)
{
Console.WriteLine($"-> {month}");
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us