w3resource logo
C# Sharp Programming Exercises

C# Sharp Exercises: Day of the week for a specified date

C# Sharp DateTime: Exercise-3 with Solution

Write a C# Sharp program to get the day of the week for a specified date.

Sample Solution:-

C# Sharp Code:

using System;

public  class Example3 
{
    public static void Main() 
    {
// Assume the current system  is en-US.
    DateTime dt = new DateTime(2016, 7, 11);
    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);
    }
}

Sample Output:

The day of the week for 7/11/2016 is Monday. 

C# Sharp Code Editor:

using System;

public  class Example3 
{
    public static void Main() 
    {
// Assume the current system  is en-US.
    DateTime dt = new DateTime(2016, 7, 11);
    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);
    }
}

Improve this sample solution and post your code through Disqus