RegionInfo.NativeName 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个国家/地区的名称,它使用该国家/地区的本地语言格式表示。
public:
virtual property System::String ^ NativeName { System::String ^ get(); };
public virtual string NativeName { get; }
[System.Runtime.InteropServices.ComVisible(false)]
public virtual string NativeName { get; }
member this.NativeName : string
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.NativeName : string
Public Overridable ReadOnly Property NativeName As String
属性值
该国家/地区的本地名称,它使用与 ISO 3166 国家/地区代码关联的语言格式表示。
- 属性
示例
下面的代码示例演示 了 NativeName 属性。
// This example demonstrates the RegionInfo.EnglishName, NativeName,
// CurrencyEnglishName, CurrencyNativeName, and GeoId properties.
using namespace System;
using namespace System::Globalization;
int main()
{
// Regional Info for Sweden
RegionInfo^ ri = gcnew RegionInfo("SE");
Console::WriteLine("Region English Name: . . . {0}", ri->EnglishName);
Console::WriteLine("Native Name: . . . . . . . {0}", ri->NativeName);
Console::WriteLine("Currency English Name: . . {0}",
ri->CurrencyEnglishName);
Console::WriteLine("Currency Native Name:. . . {0}",
ri->CurrencyNativeName);
Console::WriteLine("Geographical ID: . . . . . {0}", ri->GeoId);
}
/*
This code example produces the following results:
Region English Name: . . . Sweden
Native Name: . . . . . . . Sverige
Currency English Name: . . Swedish Krona
Currency Native Name:. . . Svensk krona
Geographical ID: . . . . . 221
*/
// This example demonstrates the RegionInfo.EnglishName, NativeName,
// CurrencyEnglishName, CurrencyNativeName, and GeoId properties.
using System;
using System.Globalization;
class Sample
{
public static void Main()
{
RegionInfo ri = new RegionInfo("SE"); // Sweden
Console.WriteLine("Region English Name: . . . {0}", ri.EnglishName);
Console.WriteLine("Native Name: . . . . . . . {0}", ri.NativeName);
Console.WriteLine("Currency English Name: . . {0}", ri.CurrencyEnglishName);
Console.WriteLine("Currency Native Name:. . . {0}", ri.CurrencyNativeName);
Console.WriteLine("Geographical ID: . . . . . {0}", ri.GeoId);
}
}
/*
This code example produces the following results:
Region English Name: . . . Sweden
Native Name: . . . . . . . Sverige
Currency English Name: . . Swedish Krona
Currency Native Name:. . . Svensk krona
Geographical ID: . . . . . 221
*/
' This example demonstrates the RegionInfo.EnglishName, NativeName,
' CurrencyEnglishName, CurrencyNativeName, and GeoId properties.
Imports System.Globalization
Class Sample
Public Shared Sub Main()
Dim ri As New RegionInfo("SE") ' Sweden
Console.WriteLine("Region English Name: . . . {0}", ri.EnglishName)
Console.WriteLine("Native Name: . . . . . . . {0}", ri.NativeName)
Console.WriteLine("Currency English Name: . . {0}", ri.CurrencyEnglishName)
Console.WriteLine("Currency Native Name:. . . {0}", ri.CurrencyNativeName)
Console.WriteLine("Geographical ID: . . . . . {0}", ri.GeoId)
End Sub
End Class
'
'This code example produces the following results:
'
'Region English Name: . . . Sweden
'Native Name: . . . . . . . Sverige
'Currency English Name: . . Swedish Krona
'Currency Native Name:. . . Svensk krona
'Geographical ID: . . . . . 221
'
注解
注意
如果RegionInfo
对象是使用完整区域性名称构造的,则 NativeName 属性将检索完整的区域性名称。
建议使用区域性名称(例如英语 (美国) 的“en-US”)来访问 NativeName 属性。 此属性使用的字符串取决于与国家/地区关联的语言。 例如,英语 (美国) 和es-US
西班牙语 (美国) 的区域性名称en-US
可以在 Windows Vista 上检索不同的值。 因此,创建 RegionInfo
仅具有国家/地区名称的对象 US
不够具体,无法区分相应的字符串。