C# DateTime.DayOfWeek Property with Example

Syntax-

DayOfWeek DateTime.DayOfWeek;

Example to demonstrate an example of DateTime.DayOfWeek 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 day of the week
            string day = dt.DayOfWeek.ToString();

            //printing the day of the week
            Console.WriteLine("Day of the week is: " + day);

            //just to print a new line
            Console.WriteLine();
        }
    }
}

Output-

Day of the week is: Thursday

Leave a Comment

error: Alert: Content is protected!!