w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Get the day and month name of current date

C# Sharp DateTime: Exercise-49 with Solution

Write a program in C# Sharp to get the day and month name of current date.

Sample Solution:-

C# Sharp Code:

using System;

class dttimeex49

{
    static void Main()
    {
    Console.Write("\n\n Display the month no. and name for the current date :\n");
	Console.Write("---------------------------------------------------------\n");	        
	DateTime now = DateTime.Now;
	Console.WriteLine(" The current Month No. is : {0} ",now.Month);
	Console.WriteLine(" The current Month is : {0}\n",now.ToString("MMMM"));
    }
}

Sample Output:

 Display the month no. and name for the current date :                                                        
---------------------------------------------------------                                                     
 The current Month No. is : 6                                                                                 
 The current Month is : June

Flowchart:

Flowchart: C# Sharp Exercises - Get the day and month name of current date

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

+

Previous: Write a program in C# Sharp to get the number of days of a given month for a year.
Next: Write a program in C# Sharp to print the name of the first three letters of month of a year starting form current date.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming