Set the Culture and UI Culture for C# Globalization

Introduction In this article I try to show like freeing the application from Windows form of the regional configuration of Windows. The two culture values of a Visual basic or Visual C# application determine what resources are loaded for an application and how information like currency, numbers and dates is formatted. The resources loaded are determined by the UI culture setting, and the formating options are determined by the culture setting.

The first place an application will search for culture valuesis the CurrentCulture and CurrentUICulture properties. You can set these values in code as shown in the following procedure.The CurrentCulture property's default value is the operating system's User Locale, which is set in the Regional Options control panel.
The CurrentUICulture property's default value is the operating system's user interface (UI) language, which is the language of your
operating system UI. On Windows 2000 and Windows XP MultiLanguage Edition, the CurrentUICulture defaults to the current user UI language settings.

If you want to override the settings of the user or operating system, set the CurrentCulture and CurrentUICulture properties. Usually, you want to specify a culture so that every part of the application's UI is appropriate to that culture. So you must set the culture before the InitializeComponent method is called.

Code of Program.cs

Collapse Copy Code
//Program.cs 
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Windows.Forms; //agregar este espacio de nombreusing System.Threading;//agregar este espacio de nombre 
 
 
namespace MiApp
{
 
static class Program    {
 
 
        [STAThread]
 
        public static void "on" />Main()"on" />
 
        {
 
            Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
 
            // Seteamos la cultura a Espa�ol Argentina            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-AR");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-AR");// 
 Application.Run(new form1());
 
 
 }
 
 
 }
 
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值