Introducing Radical.sh

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

Current Date and Time in C#

The DateTime object can be used to get the date and time.
DateTime.Now will result in current date and time.

For displaying the value to console, it is converted as string.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication3
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. DateTime dt = DateTime.Now;
  13. Console.WriteLine("Current Time is {0} ", dt.ToString());
  14. }
  15. }
  16. }


..