CultureInfo クラス

定義

特定のカルチャ (アンマネージ コードの開発では "ロケール" と呼ばれます) に関する情報を提供します。 この情報には、カルチャの名前、表記体系、使用する暦、文字列の並べ替え順序、および日付と数値の書式が含まれます。

public ref class CultureInfo : IFormatProvider
public ref class CultureInfo : ICloneable, IFormatProvider
public class CultureInfo : IFormatProvider
public class CultureInfo : ICloneable, IFormatProvider
[System.Serializable]
public class CultureInfo : ICloneable, IFormatProvider
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class CultureInfo : ICloneable, IFormatProvider
type CultureInfo = class
    interface IFormatProvider
type CultureInfo = class
    interface ICloneable
    interface IFormatProvider
[<System.Serializable>]
type CultureInfo = class
    interface ICloneable
    interface IFormatProvider
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CultureInfo = class
    interface ICloneable
    interface IFormatProvider
Public Class CultureInfo
Implements IFormatProvider
Public Class CultureInfo
Implements ICloneable, IFormatProvider
継承
CultureInfo
属性
実装

次の例は、国際並べ替えを使用してスペイン語 (スペイン) のオブジェクトを作成し、従来の並べ替えを使用して別CultureInfoのオブジェクトを作成CultureInfoする方法を示しています。

using namespace System;
using namespace System::Collections;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes the CultureInfo which uses the international sort.
   CultureInfo^ myCIintl = gcnew CultureInfo( "es-ES",false );
   
   // Creates and initializes the CultureInfo which uses the traditional sort.
   CultureInfo^ myCItrad = gcnew CultureInfo( 0x040A,false );
   
   // Displays the properties of each culture.
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL" );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "CompareInfo", myCIintl->CompareInfo, myCItrad->CompareInfo );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "DisplayName", myCIintl->DisplayName, myCItrad->DisplayName );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "EnglishName", myCIintl->EnglishName, myCItrad->EnglishName );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsNeutralCulture", myCIintl->IsNeutralCulture, myCItrad->IsNeutralCulture );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsReadOnly", myCIintl->IsReadOnly, myCItrad->IsReadOnly );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "LCID", myCIintl->LCID, myCItrad->LCID );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Name", myCIintl->Name, myCItrad->Name );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "NativeName", myCIintl->NativeName, myCItrad->NativeName );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Parent", myCIintl->Parent, myCItrad->Parent );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TextInfo", myCIintl->TextInfo, myCItrad->TextInfo );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterISOLanguageName", myCIintl->ThreeLetterISOLanguageName, myCItrad->ThreeLetterISOLanguageName );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl->ThreeLetterWindowsLanguageName, myCItrad->ThreeLetterWindowsLanguageName );
   Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TwoLetterISOLanguageName", myCIintl->TwoLetterISOLanguageName, myCItrad->TwoLetterISOLanguageName );
   Console::WriteLine();
   
   // Compare two strings using myCIintl -> 
   Console::WriteLine( "Comparing \"llegar\" and \"lugar\"" );
   Console::WriteLine( "   With myCIintl -> CompareInfo -> Compare: {0}", myCIintl->CompareInfo->Compare( "llegar", "lugar" ) );
   Console::WriteLine( "   With myCItrad -> CompareInfo -> Compare: {0}", myCItrad->CompareInfo->Compare( "llegar", "lugar" ) );
}

/*
This code produces the following output.

PROPERTY                       INTERNATIONAL                                  TRADITIONAL              
CompareInfo                    CompareInfo - es-ES                            CompareInfo - es-ES_tradnl
DisplayName                    Spanish (Spain)                                Spanish (Spain)          
EnglishName                    Spanish (Spain, International Sort)            Spanish (Spain, Traditional Sort)
IsNeutralCulture               False                                          False                    
IsReadOnly                     False                                          False                    
LCID                           3082                                           1034                     
Name                           es-ES                                          es-ES                    
NativeName                     Español (España, alfabetización internacional) Español (España, alfabetización tradicional)
Parent                         es                                             es                       
TextInfo                       TextInfo - es-ES                               TextInfo - es-ES_tradnl  
ThreeLetterISOLanguageName     spa                                            spa                      
ThreeLetterWindowsLanguageName ESN                                            ESP                      
TwoLetterISOLanguageName       es                                             es                       

Comparing "llegar" and "lugar"
   With myCIintl -> CompareInfo -> Compare: -1
   With myCItrad -> CompareInfo -> Compare: 1

*/
using System;
using System.Globalization;

public class SamplesCultureInfo
{
    public static void Main()
    {
        // Creates and initializes the CultureInfo which uses the international sort.
        CultureInfo myCIintl = new CultureInfo("es-ES", false);

        // Creates and initializes the CultureInfo which uses the traditional sort.
        CultureInfo myCItrad = new CultureInfo(0x040A, false);

        // Displays the properties of each culture.
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL");
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "CompareInfo", myCIintl.CompareInfo, myCItrad.CompareInfo);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "DisplayName", myCIintl.DisplayName, myCItrad.DisplayName);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "EnglishName", myCIintl.EnglishName, myCItrad.EnglishName);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "IsNeutralCulture", myCIintl.IsNeutralCulture, myCItrad.IsNeutralCulture);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "IsReadOnly", myCIintl.IsReadOnly, myCItrad.IsReadOnly);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "LCID", myCIintl.LCID, myCItrad.LCID);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "Name", myCIintl.Name, myCItrad.Name);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "NativeName", myCIintl.NativeName, myCItrad.NativeName);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "Parent", myCIintl.Parent, myCItrad.Parent);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "TextInfo", myCIintl.TextInfo, myCItrad.TextInfo);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "ThreeLetterISOLanguageName", myCIintl.ThreeLetterISOLanguageName, myCItrad.ThreeLetterISOLanguageName);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl.ThreeLetterWindowsLanguageName, myCItrad.ThreeLetterWindowsLanguageName);
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "TwoLetterISOLanguageName", myCIintl.TwoLetterISOLanguageName, myCItrad.TwoLetterISOLanguageName);
        Console.WriteLine();

        // Compare two strings using myCIintl.
        Console.WriteLine("Comparing \"llegar\" and \"lugar\"");
        Console.WriteLine("   With myCIintl.CompareInfo.Compare: {0}", myCIintl.CompareInfo.Compare("llegar", "lugar"));
        Console.WriteLine("   With myCItrad.CompareInfo.Compare: {0}", myCItrad.CompareInfo.Compare("llegar", "lugar"));
    }
}

/*
This code produces the following output.

PROPERTY                       INTERNATIONAL                                  TRADITIONAL
CompareInfo                    CompareInfo - es-ES                            CompareInfo - es-ES_tradnl
DisplayName                    Spanish (Spain)                                Spanish (Spain)
EnglishName                    Spanish (Spain, International Sort)            Spanish (Spain, Traditional Sort)
IsNeutralCulture               False                                          False
IsReadOnly                     False                                          False
LCID                           3082                                           1034
Name                           es-ES                                          es-ES
NativeName                     Español (España, alfabetización internacional) Español (España, alfabetización tradicional)
Parent                         es                                             es
TextInfo                       TextInfo - es-ES                               TextInfo - es-ES_tradnl
ThreeLetterISOLanguageName     spa                                            spa
ThreeLetterWindowsLanguageName ESN                                            ESP
TwoLetterISOLanguageName       es                                             es

Comparing "llegar" and "lugar"
   With myCIintl.CompareInfo.Compare: -1
   With myCItrad.CompareInfo.Compare: 1

*/
Imports System.Collections
Imports System.Globalization

Module Module1

    Public Sub Main()

        ' Creates and initializes the CultureInfo which uses the international sort.
        Dim myCIintl As New CultureInfo("es-ES", False)

        ' Creates and initializes the CultureInfo which uses the traditional sort.
        Dim myCItrad As New CultureInfo(&H40A, False)

        ' Displays the properties of each culture.
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL")
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "CompareInfo", myCIintl.CompareInfo, myCItrad.CompareInfo)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "DisplayName", myCIintl.DisplayName, myCItrad.DisplayName)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "EnglishName", myCIintl.EnglishName, myCItrad.EnglishName)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "IsNeutralCulture", myCIintl.IsNeutralCulture, myCItrad.IsNeutralCulture)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "IsReadOnly", myCIintl.IsReadOnly, myCItrad.IsReadOnly)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "LCID", myCIintl.LCID, myCItrad.LCID)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "Name", myCIintl.Name, myCItrad.Name)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "NativeName", myCIintl.NativeName, myCItrad.NativeName)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "Parent", myCIintl.Parent, myCItrad.Parent)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "TextInfo", myCIintl.TextInfo, myCItrad.TextInfo)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "ThreeLetterISOLanguageName", myCIintl.ThreeLetterISOLanguageName, myCItrad.ThreeLetterISOLanguageName)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl.ThreeLetterWindowsLanguageName, myCItrad.ThreeLetterWindowsLanguageName)
        Console.WriteLine("{0,-31}{1,-47}{2,-25}", "TwoLetterISOLanguageName", myCIintl.TwoLetterISOLanguageName, myCItrad.TwoLetterISOLanguageName)
        Console.WriteLine()

        ' Compare two strings using myCIintl.
        Console.WriteLine("Comparing ""llegar"" and ""lugar""")
        Console.WriteLine("   With myCIintl.CompareInfo.Compare: {0}", myCIintl.CompareInfo.Compare("llegar", "lugar"))
        Console.WriteLine("   With myCItrad.CompareInfo.Compare: {0}", myCItrad.CompareInfo.Compare("llegar", "lugar"))

    End Sub



'This code produces the following output.
'
'PROPERTY                       INTERNATIONAL                                  TRADITIONAL              
'CompareInfo                    CompareInfo - es-ES                            CompareInfo - es-ES_tradnl
'DisplayName                    Spanish (Spain)                                Spanish (Spain)          
'EnglishName                    Spanish (Spain, International Sort)            Spanish (Spain, Traditional Sort)
'IsNeutralCulture               False                                          False                    
'IsReadOnly                     False                                          False                    
'LCID                           3082                                           1034                     
'Name                           es-ES                                          es-ES                    
'NativeName                     Español (España, alfabetización internacional) Español (España, alfabetización tradicional)
'Parent                         es                                             es                       
'TextInfo                       TextInfo - es-ES                               TextInfo - es-ES_tradnl  
'ThreeLetterISOLanguageName     spa                                            spa                      
'ThreeLetterWindowsLanguageName ESN                                            ESP                      
'TwoLetterISOLanguageName       es                                             es                       
'
'Comparing "llegar" and "lugar"
'   With myCIintl.CompareInfo.Compare: -1
'   With myCItrad.CompareInfo.Compare: 1

End Module

注釈

この API の詳細については、「 CultureInfo の補足 API 解説」を参照してください。

コンストラクター

CultureInfo(Int32)

カルチャ識別子によって指定するカルチャに基づいて、CultureInfo クラスの新しいインスタンスを初期化します。

CultureInfo(Int32, Boolean)

カルチャ識別子で指定されたカルチャと、Windows からユーザーが選択したカルチャ設定を使用するかどうかを指定する値に基づいて、 クラスの新しいインスタンス CultureInfo を初期化します。

CultureInfo(String)

名前で指定するカルチャに基づいて、CultureInfo クラスの新しいインスタンスを初期化します。

CultureInfo(String, Boolean)

名前で指定されたカルチャと、Windows からユーザーが選択したカルチャ設定を使用するかどうかを指定する値に基づいて、 クラスの新しいインスタンス CultureInfo を初期化します。

プロパティ

Calendar

カルチャで使用する既定の暦を取得します。

CompareInfo

カルチャの文字列を比較する方法を定義する CompareInfo を取得します。

CultureTypes

現在の CultureInfo オブジェクトに関するカルチャ タイプを取得します。

CurrentCulture

現在のスレッドとタスク ベースの CultureInfo 非同期操作で使用されるカルチャを表す オブジェクトを取得または設定します。

CurrentUICulture

実行時にカルチャ固有のリソースを参照するためにリソース マネージャーによって使用される現在のユーザー インターフェイスのカルチャを表す CultureInfo オブジェクトを取得または設定します。

DateTimeFormat

カルチャに対応する、日時の表示形式を定義する DateTimeFormatInfo を取得または設定します。

DefaultThreadCurrentCulture

現在のアプリケーション ドメインのスレッドの既定のカルチャを取得または設定します。

DefaultThreadCurrentUICulture

現在のアプリケーション ドメイン内のスレッドの既定 UI カルチャを取得または設定します。

DisplayName

完全にローカライズされたカルチャ名を取得します。

EnglishName

英語で表した "languagefull [country/regionfull]" という形式のカルチャ名を取得します。

IetfLanguageTag

非推奨になりました。 言語の RFC 4646 標準 ID を取得します。

InstalledUICulture

オペレーティング システムと共にインストールされたカルチャを表す CultureInfo を取得します。

InvariantCulture

カルチャに依存しない (インバリアントな) CultureInfo オブジェクトを取得します。

IsNeutralCulture

現在の CultureInfo がニュートラル カルチャを表しているかどうかを示す値を取得します。

IsReadOnly

現在の CultureInfo が読み取り専用かどうかを示す値を取得します。

KeyboardLayoutId

アクティブな入力ロケール識別子を取得します。

LCID

現在の CultureInfo のカルチャ識別子を取得します。

Name

languagecode2-country/regioncode2 という形式のカルチャ名を取得します。

NativeName

カルチャの表示設定である、言語、国/地域、およびオプションのスクリプトで構成されるカルチャ名を取得します。

NumberFormat

数値、通貨、割合を表示する、カルチャに対応する書式を定義する NumberFormatInfo を取得または設定します。

OptionalCalendars

カルチャで使用できる暦の一覧を取得します。

Parent

現在の CultureInfo の親カルチャを表す CultureInfo を取得します。

TextInfo

カルチャに関連付けられている書記体系を定義する TextInfo を取得します。

ThreeLetterISOLanguageName

現在の CultureInfo の言語に対する ISO 639-2 の 3 桁の文字コードを取得します。

ThreeLetterWindowsLanguageName

Windows API の定義に従って、言語に対する 3 文字コードを取得します。

TwoLetterISOLanguageName

現在 CultureInfoの の言語の ISO 639-1 2 文字または ISO 639-3 3 文字コードを取得します。

UseUserOverride

現在の CultureInfo オブジェクトでユーザーが選択したカルチャ設定を使用するかどうかを示す値を取得します。

メソッド

ClearCachedData()

キャッシュされたカルチャ関連情報を更新します。

Clone()

現在の CultureInfo のコピーを作成します。

CreateSpecificCulture(String)

指定した名前に関連付けられている特定のカルチャを表す CultureInfo を作成します。

Equals(Object)

指定したオブジェクトが現在の CultureInfo と同じカルチャかどうかを判断します。

GetConsoleFallbackUICulture()

グラフィック ユーザー インターフェイスの既定のカルチャが不適切な場合、コンソール アプリケーションに適した代替のユーザー インターフェイス カルチャを取得します。

GetCultureInfo(Int32)

指定されたカルチャ識別子を使用して、カルチャのキャッシュされた読み取り専用インスタンスを取得します。

GetCultureInfo(String)

指定されたカルチャ名を使用して、カルチャのキャッシュされた読み取り専用インスタンスを取得します。

GetCultureInfo(String, Boolean)

カルチャのキャッシュされた読み取り専用インスタンスを取得します。

GetCultureInfo(String, String)

カルチャのキャッシュされた読み取り専用インスタンスを取得します。 パラメーターは、別のカルチャで指定された TextInfo オブジェクトおよび CompareInfo オブジェクトで初期化されたカルチャを指定します。

GetCultureInfoByIetfLanguageTag(String)

非推奨になりました。 指定された RFC 4646 言語タグで示される言語特性を持つ、読み取り専用 CultureInfo オブジェクトを取得します。

GetCultures(CultureTypes)

サポートされているカルチャを、指定した CultureTypes パラメーターでフィルター処理した結果のリストを取得します。

GetFormat(Type)

指定した型に書式指定する方法を定義するオブジェクトを取得します。

GetHashCode()

現在の CultureInfo のハッシュ関数として機能します。ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ReadOnly(CultureInfo)

指定した CultureInfo オブジェクトをラップする読み取り専用のラッパーを返します。

ToString()

languagecode2-country/regioncode2 という形式で、現在の CultureInfo の名前を格納している文字列を返します。

適用対象

こちらもご覧ください