Defines a custom culture that is new or based on another culture and country/region. The custom culture can be installed on a computer and subsequently used by any application that is running on that computer. This class cannot be inherited.
public ref class CultureAndRegionInfoBuilder sealed
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class CultureAndRegionInfoBuilder
[<System.Runtime.InteropServices.ComVisible(false)>]
type CultureAndRegionInfoBuilder = class
Public NotInheritable Class CultureAndRegionInfoBuilder
For more information about this API, see Supplemental API remarks for CultureAndRegionInfoBuilder.
ExampleThe following example defines a custom ru-US culture that represents the Russian language in the United States. The example defines the custom culture by loading settings from the Russian (Russia) CultureInfo object and the U.S. RegionInfo object, and then sets a number of CultureAndRegionInfoBuilder properties. The example registers the custom culture, and then instantiates it and makes it the current culture.
using System;
using System.Globalization;
using System.Threading;
public class Example
{
public static void Main()
{
// Create a custom culture for ru-US.
CultureAndRegionInfoBuilder car1 = new CultureAndRegionInfoBuilder("ru-US",
CultureAndRegionModifiers.None);
car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"));
car1.LoadDataFromRegionInfo(new RegionInfo("en-US"));
car1.CultureEnglishName = "Russian (United States)";
car1.CultureNativeName = "ÑÑÑÑкий (СШÐ)";
car1.CurrencyNativeName = "ÐÐ¾Ð»Ð»Ð°Ñ (СШÐ)";
car1.RegionNativeName = "СШÐ";
// Register the culture.
try {
car1.Register();
}
catch (InvalidOperationException) {
// Swallow the exception: the culture already is registered.
}
// Use the custom culture.
CultureInfo ci = CultureInfo.CreateSpecificCulture("ru-US");
Thread.CurrentThread.CurrentCulture = ci;
Console.WriteLine("Current Culture: {0}",
Thread.CurrentThread.CurrentCulture.Name);
Console.WriteLine("Writing System: {0}",
Thread.CurrentThread.CurrentCulture.TextInfo);
}
}
// The example displays the following output:
// Current Culture: ru-US
// Writing System: TextInfo - ru-US
Imports System.Globalization
Imports System.Threading
Module Example
Public Sub Main()
' Create a custom culture for ru-US.
Dim car1 As New CultureAndRegionInfoBuilder("ru-US", CultureAndRegionModifiers.None)
car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"))
car1.LoadDataFromRegionInfo(New RegionInfo("en-US"))
car1.CultureEnglishName = "Russian (United States)"
car1.CultureNativeName = "ÑÑÑÑкий (СШÐ)"
car1.CurrencyNativeName = "ÐÐ¾Ð»Ð»Ð°Ñ (СШÐ)"
car1.RegionNativeName = "СШÐ"
' Register the culture.
Try
car1.Register()
Catch e As InvalidOperationException
' Swallow the exception: the culture already is registered.
End Try
' Use the custom culture.
Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("ru-US")
Thread.CurrentThread.CurrentCulture = ci
Console.WriteLine("Current Culture: {0}",
Thread.CurrentThread.CurrentCulture.Name)
Console.WriteLine("Writing System: {0}",
Thread.CurrentThread.CurrentCulture.TextInfo)
End Sub
End Module
' The example displays the following output:
' Current Culture: ru-US
' Writing System: TextInfo - ru-US
Constructors Properties Methods
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4