i just need some guidance on how i can display which dates in the month fall on that day. For example, if user enters 0 for monday and 31 days in that month, it will display all the momdays and which date the mondays correspond to in that month? thanks i have this so far but it doesnt seem to work for user input.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calendar
{
class Program
{
static int startDay = new int();
static int totalDays = new int();
static void Main(string[] args)
{
Console.Write("Enter the day the first falls on (Mon = 0, etc): ");
startDay = Convert.ToInt32(Console.ReadLine());
Console.Write("How many days in the month? ");
totalDays = Convert.ToInt32(Console.ReadLine());
}
public static List<DateTime> getDates()
{
List<DateTime> lstSundays = new List<DateTime>();
int intMonth = DateTime.Now.Month;
int intYear = DateTime.Now.Year;
int intDaysThisMonth = DateTime.DaysInMonth(intYear, intMonth);
DateTime oBeginnngOfThisMonth = new DateTime(intYear, intMonth, 1);
for (int i = 1; i < intDaysThisMonth + 1; i++)
{
if (oBeginnngOfThisMonth.AddDays(i).DayOfWeek == DayOfWeek.Sunday)
{
lstSundays.Add(new DateTime(intYear, intMonth, i));
}
}
return lstSundays;
}
}
}