Syntax-
TimeSpan DateTime.Year;
Example to demonstrate an example of DateTime.TimeOfDay Property
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//creating an object of DateTime class
//and, initializing it with the current time
//using "Now"
DateTime dt = DateTime.Now;
//getting the time of the day
string time = dt.TimeOfDay.ToString();
//printing current date & time
Console.WriteLine("Current date & time is: " + dt.ToString());
//printing the day of the week
Console.WriteLine("The time is : " + time);
//just to print a new line
Console.WriteLine();
}
}
}
Output-
Current date & time is: 10/24/2019 8:23:35 AM
The time is : 08:23:35.9734600