本文整理汇总了VB.NET中System.Globalization.CultureInfo.InvariantCulture属性的典型用法代码示例。如果您正苦于以下问题:VB.NET CultureInfo.InvariantCulture属性的具体用法?VB.NET CultureInfo.InvariantCulture怎么用?VB.NET CultureInfo.InvariantCulture使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Globalization.CultureInfo 的用法示例。
在下文中一共展示了CultureInfo.InvariantCulture属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Globalization
Imports System.IO
Module Example
Public Sub Main()
' Persist the date and time data.
Dim sw As New StreamWriter(".\DateData.dat")
' Create a DateTime value.
Dim dtIn As DateTime = DateTime.Now
' Retrieve a CultureInfo object.
Dim invC As CultureInfo = CultureInfo.InvariantCulture
' Convert the date to a string and write it to a file.
sw.WriteLine(dtIn.ToString("r", invC))
sw.Close()
' Restore the date and time data.
Dim sr As New StreamReader(".\DateData.dat")
Dim input As String = String.Empty
Do While sr.Peek() >= 0
input = sr.ReadLine()
Console.WriteLine("Stored data: {0}" , input)
Console.WriteLine()
' Parse the stored string.
Dim dtOut As DateTime = DateTime.Parse(input, invC, DateTimeStyles.RoundtripKind)
' Create a French (France) CultureInfo object.
Dim frFr As New CultureInfo("fr-FR")
' Displays the date formatted for the "fr-FR" culture.
Console.WriteLine("Date formatted for the {0} culture: {1}" ,
frFr.Name, dtOut.ToString("f", frFr))
' Creates a German (Germany) CultureInfo object.
Dim deDe As New CultureInfo("de-De")
' Displays the date formatted for the "de-DE" culture.
Console.WriteLine("Date formatted for {0} culture: {1}" ,
deDe.Name, dtOut.ToString("f", deDe))
Loop
sr.Close()
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Globalization,代码行数:44,代码来源:CultureInfo.InvariantCulture 输出:
Stored data: Tue, 15 May 2012 16:34:16 GMT
Date formatted for the fr-FR culture: mardi 15 mai 2012 16:34
Date formatted for de-DE culture: Dienstag, 15. Mai 2012 16:34
注:本文中的System.Globalization.CultureInfo.InvariantCulture属性示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论