Thursday 15 April 2010

c# - How does one set text of two labels with two different cultural/region format options? -


How does the text of two labels with two different cultural / region format options set? For the first code, ar-EG: Arabic - Egypt and the other one en-US: English - United States ?

This is done for number / date / time / currency formats.

Use the culture explicitly in the ToString () method. For example:

  datetime DT = date time.Now; CultureInfo Arabic = Culture Info GatecultureInfo ("AR-EG"); Label1.Text = dt.ToString (Arabic datetime format); CultureInfo English = CultureInfoGetCalcherInfo ("N-US"); Label2.Text = dt.ToString (english.DateTimeFormat);  

Use CultureInfo.NumberFormat for format numbers.


No comments:

Post a Comment