Below are the steps to get user's culture at run time.
1. In the first step, you have to get the Request object’s UserLanguages property.
2. Then, you have to use the returned value with the CultureInfo class to create an object representing the user’s current culture.
The following code gets the user’s culture and displays the English name and the abbreviated name of the culture in a label the first time the page is displayed:
private void Page_Load(object sender, System.EventArgs e)
// Run the first time the page is displayed
// Get the user's preferred language.
string sLang = Request.UserLanguages;
// Create a CultureInfo object from it.
CultureInfo CurrentCulture = new CultureInfo(sLang);
lblCulture.Text = CurrentCulture.EnglishName + ": " +
Asked In: Many Interviews |