DateTime dt = DateTime.Now; MessageBox.Show("DayOfWeek=" + dt.Date.DayOfWeek.ToString());
DayOfWeek= Sunday
DayOfWeek= الاحد
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Globalization; using System.Threading; namespace ToCodeProject { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string[] strArr; //Get current culture of application: CultureInfo UsersCulture = Thread.CurrentThread.CurrentCulture; MessageBox.Show("The current culture of this application is : " + UsersCulture.Name); //We will change this to English/USA Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); MessageBox.Show("The current culture of this application is : " + Thread.CurrentThread.CurrentCulture); strArr = Thread.CurrentThread.CurrentCulture.DateTimeFormat.AbbreviatedMonthGenitiveNames; for (int i = 0; i < 12; i++) MessageBox.Show(strArr[i]);//Jan Feb Mar ... strArr = Thread.CurrentThread.CurrentCulture.DateTimeFormat.AbbreviatedDayNames;// will be written in Arabic like السبت الاحد الاثنيين .... for (int i = 0; i < 7; i++) MessageBox.Show(strArr[i]);// Sat Sun Mon ... //We will change this to Arabic/Saudia arabia //Set current culture of application: Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-SA"); MessageBox.Show("The current culture of this application is : " + Thread.CurrentThread.CurrentCulture); strArr = Thread.CurrentThread.CurrentCulture.DateTimeFormat.AbbreviatedMonthGenitiveNames; for (int i = 0; i < 12; i++) MessageBox.Show(strArr[i]);//محرم صفر ربيع ... strArr = Thread.CurrentThread.CurrentCulture.DateTimeFormat.AbbreviatedDayNames;// will be written in Arabic like السبت الاحد الاثنيين .... for (int i = 0; i < 7; i++) MessageBox.Show(strArr[i]);// السبت الاحد الاثنيين ....<------------Line A // change the keyboard language //http://www.microsoft.com/middleeast/msdn/WinFormsAndArabic.aspx#_Toc136842137 InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(Application.CurrentCulture);//Set language to current culture InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new CultureInfo("ar-SA"));// set it to Arabic saudia arabia DateTime dt = DateTime.Now; MessageBox.Show("DayOfWeek=" + dt.Date.DayOfWeek.ToString());//<-------- i need day of the week in arabic name not in english } } }
DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("ar-AE"))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)