本文整理匯總了VB.NET中System.UInt16.ToString方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET UInt16.ToString方法的具體用法?VB.NET UInt16.ToString怎麽用?VB.NET UInt16.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了UInt16.ToString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.Globalization
Module Example
Public Sub Main()
' Define an array of CultureInfo objects.
Dim ci() As CultureInfo = { New CultureInfo("en-US"), _
New CultureInfo("fr-FR"), _
CultureInfo.InvariantCulture }
Dim value As UInt16 = 18924
Console.WriteLine(" {0,12} {1,12} {2,12}", _
GetName(ci(0)), GetName(ci(1)), GetName(ci(2)))
Console.WriteLine(" {0,12} {1,12} {2,12}", _
value.ToString(ci(0)), value.ToString(ci(1)), value.ToString(ci(2)))
End Sub
Private Function GetName(ci As CultureInfo) As String
If ci.Equals(CultureInfo.InvariantCulture) Then
Return "Invariant"
Else
Return ci.Name
End If
End Function
End Module
輸出:
en-US fr-FR Invariant 18924 18924 18924
示例2: Example
' 導入命名空間
Imports System.Globalization
Module Example
Public Sub Main()
' 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 specifiers() As String = {"G", "C", "D4", "E2", "F", "N", "P", "X2"}
Dim value As UShort = 22042
For Each specifier As String In specifiers
For Each culture As CultureInfo In Cultures
Console.WriteLine("{0,2} format using {1} culture: {2, 16}", _
specifier, culture.Name, _
value.ToString(specifier, culture))
Next
Console.WriteLine()
Next
End Sub
End Module
輸出:
G format using en-US culture: 22042 G format using fr-FR culture: 22042 G format using es-ES culture: 22042 C format using en-US culture: $22,042.00 C format using fr-FR culture: 22 042,00 € C format using es-ES culture: 22.042,00 € D4 format using en-US culture: 22042 D4 format using fr-FR culture: 22042 D4 format using es-ES culture: 22042 E2 format using en-US culture: 2.20E+004 E2 format using fr-FR culture: 2,20E+004 E2 format using es-ES culture: 2,20E+004 F format using en-US culture: 22042.00 F format using fr-FR culture: 22042,00 F format using es-ES culture: 22042,00 N format using en-US culture: 22,042.00 N format using fr-FR culture: 22 042,00 N format using es-ES culture: 22.042,00 P format using en-US culture: 2,204,200.00 % P format using fr-FR culture: 2 204 200,00 % P format using es-ES culture: 2.204.200,00 % X2 format using en-US culture: 561A X2 format using fr-FR culture: 561A X2 format using es-ES culture: 561A
示例3: Example
' 導入命名空間
Imports System.Globalization
Module Example
Public Sub Main()
Dim value As UShort = 21708
Dim specifiers() As String = { "G", "C", "D3", "E2", "e3", "F", _
"N", "P", "X", "000000.0", "#.0", _
"00000000;(0);**Zero**" }
For Each specifier As String In specifiers
Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
Next
End Sub
End Module
輸出:
G: 21708 C: $21,708.00 D3: 21708 E2: 2.17E+004 e3: 2.171e+004 F: 21708.00 N: 21,708.00 P: 2,170,800.00 % X: 54CC 000000.0: 021708.0 #.0: 21708.0 00000000;(0);**Zero**: 00021708
示例4: Example
Module Example
Public Sub Main()
Dim value As UInt16 = 16324
' Display value using default ToString method.
Console.WriteLine(value.ToString())
Console.WriteLine()
' Define an array of format specifiers.
Dim formats() As String = { "G", "C", "D", "F", "N", "X" }
' Display value using the standard format specifiers.
For Each format As String In formats
Console.WriteLine("{0} format specifier: {1,12}", _
format, value.ToString(format))
Next
End Sub
End Module
輸出:
16324 G format specifier: 16324 C format specifier: $16,324.00 D format specifier: 16324 F format specifier: 16324.00 N format specifier: 16,324.00 X format specifier: 3FC4