w3resource logo


C# Sharp Programming Exercises

C# Sharp Exercises: Display the string representation of a date using the long date format

Secondary Nav

C# Sharp DateTime : Exercise-25 with Solution

Write a C# Sharp program to display the string representation of a date using the long date format.

Expected Output :

Friday, August 14, 2009 

C# Sharp Code:

using System;  
public class Exercise25  
{  
    public static void Main()  
{  
   DateTime august14 = new DateTime(2009, 8, 14, 5, 23, 15);

// Get the long date formats using the current culture.
string [] longaugust14Formats = 
			august14.GetDateTimeFormats('D');

// Display all long date formats.
foreach (string format in longaugust14Formats) {
	Console.WriteLine(format);
}
  }
}

C# Sharp Practice online:

using System;  
public class Exercise25  
{  
    public static void Main()  
{  
   DateTime august14 = new DateTime(2009, 8, 14, 5, 23, 15);

// Get the long date formats using the current culture.
string [] longaugust14Formats = 
			august14.GetDateTimeFormats('D');

// Display all long date formats.
foreach (string format in longaugust14Formats) {
	Console.WriteLine(format);
}
  }
}

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