CSharp - Write program to Get current Date and Time

Requirements

You will write a program that displays the current date and time.

Hint

DateTime type contains various components of a single instance of time, such as day, month, year, hour, minute, second, and so on.

Demo

using System;

class Program//from  w ww  . j a va2  s  . co  m
{
    static void Main(string[] args)
    {
        // Variable of DateTime type, at first empty 
        DateTime now;

        // Storing of current date and time into our variable 
        now = DateTime.Now;

        // Output 
        Console.WriteLine("Now is " + now);

    }
}

Result