Introducing Radical.sh

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

Printing current year in C#

The code below is used to display the current year.

  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. Console.WriteLine(now.ToString("yyyy"));
  11. }
  12.  
  13. }
  14. }


Output:
2012