當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET CultureInfo.CurrentCulture屬性代碼示例

本文整理匯總了VB.NET中System.Globalization.CultureInfo.CurrentCulture屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET CultureInfo.CurrentCulture屬性的具體用法?VB.NET CultureInfo.CurrentCulture怎麽用?VB.NET CultureInfo.CurrentCulture使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Globalization.CultureInfo的用法示例。


在下文中一共展示了CultureInfo.CurrentCulture屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Example

' 導入命名空間
Imports System.Globalization
Imports System.Threading

Public Module Example
   Public Sub Main()

      ' Display the name of the current thread culture.
      Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name)

      ' Change the current culture to th-TH.
      CultureInfo.CurrentCulture = New CultureInfo("th-TH", False)
      Console.WriteLine("CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name)

      ' Display the name of the current UI culture.
      Console.WriteLine("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name)

      ' Change the current UI culture to ja-JP.
      CultureInfo.CurrentUICulture = New CultureInfo("ja-JP", False)
      Console.WriteLine("CurrentUICulture is now {0}.", CultureInfo.CurrentUICulture.Name)
   End Sub 
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:22,代碼來源:CultureInfo.CurrentCulture

輸出:

CurrentCulture is en-US.
CurrentCulture is now th-TH.
CurrentUICulture is en-US.
CurrentUICulture is now ja-JP.

示例2: Example

' 導入命名空間
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Runtime.Versioning
Imports System.Threading
Imports System.Threading.Tasks

<assembly:TargetFramework(".NETFramework,Version=v4.6")>

Module Example
   Public Sub Main()
      Dim tasks As New List(Of Task)
      Console.WriteLine("The current culture is {0}", 
                        Thread.CurrentThread.CurrentCulture.Name)
      Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-BR")
      ' Change the current culture to Portuguese (Brazil).
      Console.WriteLine("Current culture changed to {0}",
                        Thread.CurrentThread.CurrentCulture.Name)
      Console.WriteLine("Application thread is thread {0}",
                        Thread.CurrentThread.ManagedThreadId)
      ' Launch six tasks and display their current culture.
      For ctr As Integer = 0 to 5
         tasks.Add(Task.Run(Sub()
                               Console.WriteLine("Culture of task {0} on thread {1} is {2}",
                                                 Task.CurrentId, 
                                                 Thread.CurrentThread.ManagedThreadId,
                                                 Thread.CurrentThread.CurrentCulture.Name)
                            End Sub))                     
      Next
      Task.WaitAll(tasks.ToArray())
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:32,代碼來源:CultureInfo.CurrentCulture

輸出:

The current culture is en-US
Current culture changed to pt-BR
Application thread is thread 9
Culture of task 2 on thread 11 is pt-BR
Culture of task 1 on thread 10 is pt-BR
Culture of task 3 on thread 11 is pt-BR
Culture of task 5 on thread 11 is pt-BR
Culture of task 6 on thread 11 is pt-BR
Culture of task 4 on thread 10 is pt-BR

示例3: Example

' 導入命名空間
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim culture As CultureInfo = CultureInfo.CurrentCulture
      Console.WriteLine("The current culture is {0} [{1}]",
                        culture.NativeName, culture.Name)
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:10,代碼來源:CultureInfo.CurrentCulture

輸出:

The current culture is English (United States) [en-US]

示例4: Example

' 導入命名空間
Imports System.Globalization
Imports System.Threading

Public Class Info : Inherits MarshalByRefObject
   Public Sub ShowCurrentCulture()
      Console.WriteLine("Culture of {0} in application domain {1}: {2}",
                        Thread.CurrentThread.Name,
                        AppDomain.CurrentDomain.FriendlyName,
                        CultureInfo.CurrentCulture.Name)
   End Sub
End Class

Module Example
   Public Sub Main()
      Dim inf As New Info()
      ' Set the current culture to Dutch (Netherlands).
      Thread.CurrentThread.Name = "MainThread"
      CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL")
      inf.ShowCurrentCulture()
      
      ' Create a new application domain.
       Dim ad As AppDomain = AppDomain.CreateDomain("Domain2")
       Dim inf2 As Info = CType(ad.CreateInstanceAndUnwrap(GetType(Info).Assembly.FullName, "Info"),
                          Info)  
       inf2.ShowCurrentCulture()                       
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:28,代碼來源:CultureInfo.CurrentCulture

輸出:

Culture of MainThread in application domain Example.exe: nl-NL
Culture of MainThread in application domain Domain2: nl-NL

示例5: Example

' 導入命名空間
Imports System.Globalization
Imports System.Threading

Module Example
   Public Sub Main()
      Dim value As Double = 1634.92
      CultureInfo.CurrentCulture = New CultureInfo("fr-CA")
      Console.WriteLine("Current Culture: {0}", 
                        CultureInfo.CurrentCulture.Name)
      Console.WriteLine("{0:C2}", value)
      Console.WriteLine()
      
      Thread.CurrentThread.CurrentCulture = New CultureInfo("fr")
      Console.WriteLine("Current Culture: {0}", 
                        CultureInfo.CurrentCulture.Name)
      Console.WriteLine("{0:C2}", value)
   End Sub
End Module
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:19,代碼來源:CultureInfo.CurrentCulture

輸出:

Current Culture: fr-CA
1 634,92 $

Current Culture: fr
1 634,92 €


注:本文中的System.Globalization.CultureInfo.CurrentCulture屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。