Display Every week until end of year - CSharp Language Basics

CSharp examples for Language Basics:Date Time

Description

Display Every week until end of year

Demo Code

using System;// ww w. j av  a 2s. c o m
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Today
      DateTime today = DateTime.Today;
      int thisYear = today.Year;
      // Repeating
      DateTime date = today;
      do
      {
         // Output
         Console.WriteLine(date.ToLongDateString());
         // Preparing next output (a week later)
         date = date.AddDays(7);
      } while (date.Year == thisYear);
   }
}

Result


Related Tutorials