Write a C# Sharp program to get a DateTime value that represents the current date and time on the local computer

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

Write a C# Sharp program to get a DateTime value that represents the current date and time on the local computer.

Expected Output :

English (Ireland):                                                      
   Local date and time: 20/08/2016 15:49:03, Local                      
   UTC date and time: 20/08/2016 10:19:03, Utc                          
                                                                        
English (South Africa):                                                 
   Local date and time: 2016-08-20 03:49:03 PM, Local                   
   UTC date and time: 2016-08-20 10:19:03 AM, Utc

الأجوبة

using System;
using System.Globalization;
public class Example5
{
   public static void Main()
   {
      DateTime localDate = DateTime.Now;
      DateTime utcDate = DateTime.UtcNow;
      String[] cultureNames = { "en-IE", "en-ZA", "fr-CA",
                                "de-CH", "ro-RO" } ;
      foreach (var cultureName in cultureNames) {
         var culture = new CultureInfo(cultureName);
         Console.WriteLine("{0}:", culture.NativeName);
         Console.WriteLine("   Local date and time: {0}, {1:G}",
                           localDate.ToString(culture), localDate.Kind);
         Console.WriteLine("   UTC date and time: {0}, {1:G}\n",
                           utcDate.ToString(culture), utcDate.Kind);
      }
   }
}
هل كان المحتوى مفيد؟

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

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