Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created September 17, 2024 21:57
Show Gist options
  • Save YurePereira/b796e179707bb7a8c3db8882dcc257cd to your computer and use it in GitHub Desktop.
Save YurePereira/b796e179707bb7a8c3db8882dcc257cd to your computer and use it in GitHub Desktop.
Calendário simples com C# por console.
using System;
class Program
{
static void Main()
{
int year = 2024; // Ano que você deseja gerar o calendário
for (int month = 1; month <= 12; month++)
{
Console.WriteLine($"Mês: {month}");
int daysInMonth = DateTime.DaysInMonth(year, month);
for (int day = 1; day <= daysInMonth; day++)
{
DateTime date = new DateTime(year, month, day);
String diaSemana = $"{date:dddd}";
Console.Write($"{date:dd/MM/yyyy} - {date:dddd}");
if (diaSemana == "Sunday") {
Console.WriteLine("");
}
}
Console.WriteLine();
}
}
}
@YurePereira
Copy link
Author

@YurePereira
Copy link
Author

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment