本文整理汇总了VB.NET中System.Int32.ToString方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Int32.ToString方法的具体用法?VB.NET Int32.ToString怎么用?VB.NET Int32.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Int32 的用法示例。
在下文中一共展示了Int32.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1:
Dim value As Integer = -16325
' Display value using the invariant culture.
Console.WriteLine(value.ToString(CultureInfo.InvariantCulture))
' Display value using the en-GB culture.
Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB")))
' Display value using the de-DE culture.
Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("de-DE")))
' This example displays the following output to the console:
' -16325
' -16325
' -16325
开发者ID:VB.NET开发者,项目名称:System,代码行数:11,代码来源:Int32.ToString
示例2: cultures
' Define cultures whose formatting conventions are to be used.
Dim cultures() As CultureInfo = {CultureInfo.CreateSpecificCulture("en-US"), _
CultureInfo.CreateSpecificCulture("fr-FR"), _
CultureInfo.CreateSpecificCulture("es-ES") }
Dim positiveNumber As Integer = 1679
Dim negativeNumber As Integer = -3045
Dim specifiers() As String = {"G", "C", "D8", "E2", "F", "N", "P", "X8"}
For Each specifier As String In specifiers
For Each culture As CultureInfo In Cultures
' Display values with "G" format specifier.
Console.WriteLine("{0} format using {1} culture: {2, 16} {3, 16}", _
specifier, culture.Name, _
positiveNumber.ToString(specifier, culture), _
negativeNumber.ToString(specifier, culture))
Next
Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:19,代码来源:Int32.ToString 输出:
G format using en-US culture: 1679 -3045
G format using fr-FR culture: 1679 -3045
G format using es-ES culture: 1679 -3045
C format using en-US culture: $1,679.00 ($3,045.00)
C format using fr-FR culture: 1 679,00 € -3 045,00 €
C format using es-ES culture: 1.679,00 € -3.045,00 €
D8 format using en-US culture: 00001679 -00003045
D8 format using fr-FR culture: 00001679 -00003045
D8 format using es-ES culture: 00001679 -00003045
E2 format using en-US culture: 1.68E+003 -3.05E+003
E2 format using fr-FR culture: 1,68E+003 -3,05E+003
E2 format using es-ES culture: 1,68E+003 -3,05E+003
F format using en-US culture: 1679.00 -3045.00
F format using fr-FR culture: 1679,00 -3045,00
F format using es-ES culture: 1679,00 -3045,00
N format using en-US culture: 1,679.00 -3,045.00
N format using fr-FR culture: 1 679,00 -3 045,00
N format using es-ES culture: 1.679,00 -3.045,00
P format using en-US culture: 167,900.00 % -304,500.00 %
P format using fr-FR culture: 167 900,00 % -304 500,00 %
P format using es-ES culture: 167.900,00 % -304.500,00 %
X8 format using en-US culture: 0000068F FFFFF41B
X8 format using fr-FR culture: 0000068F FFFFF41B
X8 format using es-ES culture: 0000068F FFFFF41B
示例3:
Dim value As Integer = -16325
Dim specifier As String
' Use standard numeric format specifier.
specifier = "G"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: G: -16325
specifier = "C"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: C: ($16,325.00)
specifier = "D8"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: D8: -00016325
specifier = "E4"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: E4: -1.6325E+004
specifier = "e3"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: e3: -1.633e+004
specifier = "F"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: F: -16325.00
specifier = "N"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: N: -16,325.00
specifier = "P"
Console.WriteLine("{0}: {1}", specifier, (value/100000).ToString(specifier))
' Displays: P: -16.33 %
specifier = "X"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: X: FFFFC03B
' Use custom numeric format specifiers.
specifier = "0,0.000"
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
' Displays: 0,0.000: -16,325.000
specifier = "#,#.00#;(#,#.00#)"
Console.WriteLine("{0}: {1}", specifier, (value*-1).ToString(specifier))
' Displays: #,#.00#;(#,#.00#): 16,325.00
开发者ID:VB.NET开发者,项目名称:System,代码行数:39,代码来源:Int32.ToString
示例4: Displays
Dim value As Integer = -16325
' Display value using default ToString method.
Console.WriteLine(value.ToString()) ' Displays -16325
' Display value using some standard format specifiers.
Console.WriteLine(value.ToString("G")) ' Displays -16325
Console.WriteLine(value.ToString("C")) ' Displays ($16,325.00)
Console.WriteLine(value.ToString("D")) ' Displays -16325
Console.WriteLine(value.ToString("F")) ' Displays -16325.00
Console.WriteLine(value.ToString("N")) ' Displays -16,325.00
Console.WriteLine(value.ToString("X")) ' Displays FFFFC03B
开发者ID:VB.NET开发者,项目名称:System,代码行数:10,代码来源:Int32.ToString
注:本文中的System.Int32.ToString方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论