Created
September 17, 2024 21:57
-
-
Save YurePereira/b796e179707bb7a8c3db8882dcc257cd to your computer and use it in GitHub Desktop.
Calendário simples com C# por console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dotnetfiddle.net/E7TkVE