Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Printing days in a week in C#

Often you need to display the complete day of the week in your C# code.
This simple program shows all seven different day strings you can get from the dddd format.

  1. using System;
  2.  
  3. namespace forgetCode
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. DateTime now = DateTime.Today;
  10. for (int i = 0; i < 7; i++)
  11. {
  12. Console.WriteLine(now.ToString("dddd"));
  13. now = now.AddDays(1);
  14. }
  15. }
  16.  
  17. }
  18. }


Output:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

..