Write a C# Sharp program to convert the value of the current DateTime object to its equivalent string representation using the formatting conventions of the current culture

  • برمجة سي شارب
  • برمجة

 Write a C# Sharp program to convert the value of the current DateTime object to its equivalent string representation using the formatting conventions of the current culture. 

Expected Output :

5/16/2016 6:32:06 PM

16/05/2016 18:32:06

2016/05/16 18:32:06

الأجوبة

using System;
using System.Globalization;
using System.Threading;

public class Example36
{
   public static void Main()
   {
      CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
      DateTime exampleDate = new DateTime(2016, 5, 16, 18, 32, 6);

      // Display the date using the current (en-US) culture.
      Console.WriteLine(exampleDate.ToString());

      // Change the current culture to fr-FR and display the date.
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-FR");
      Console.WriteLine(exampleDate.ToString());

      // Change the current culture to ja-JP and display the date.
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ja-JP");
      Console.WriteLine(exampleDate.ToString());

      // Restore the original culture
      Thread.CurrentThread.CurrentCulture = currentCulture;
   }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...