w3resource logo


C# Sharp Programming Exercises

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

Secondary Nav

C# Sharp DateTime : Exercise-49 with Solution

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

Expected Output :

The current Month No. is : 9
 The current Month is : September 

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"));
    }
}

C# Sharp Practice online:

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"));
    }
}

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program