Regional formatting is how various information, such as currency, date and time, and so on, is displayed according to different regions of the world. In this recipe, we will discuss how to display formatted numbers and dates according to the user's regional formatting settings.
Add five labels on the view of
MainController
. Enter the following code in theMainController
class:public override void ViewDidAppear (bool animated){ base.ViewDidAppear (animated); this.lblLocale.Text = string.Format("Locale: {0}", NSLocale.CurrentLocale.LocaleIdentifier); this.lblDate.Text = string.Format("Date: {0}", DateTime.Now.ToLongDateString()); this.lblTime.Text = string.Format("Time: {0}", DateTime.Now.ToLongTimeString()); this.lblCurrency.Text = string.Format("Currency: {0:c}", 250); this.lblNumber.Text = string.Format("Number: {0:n}", 1350); }
Compile and run the application...