本文整理匯總了VB.NET中System.Globalization.NumberFormatInfo.NumberGroupSizes屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET NumberFormatInfo.NumberGroupSizes屬性的具體用法?VB.NET NumberFormatInfo.NumberGroupSizes怎麽用?VB.NET NumberFormatInfo.NumberGroupSizes使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Globalization.NumberFormatInfo
的用法示例。
在下文中一共展示了NumberFormatInfo.NumberGroupSizes屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: NumberFormatInfoSample
' 導入命名空間
Imports System.Globalization
Class NumberFormatInfoSample
Public Shared Sub Main()
' Gets a NumberFormatInfo associated with the en-US culture.
Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
' Displays a value with the default separator (".").
Dim myInt As Int64 = 123456789012345
Console.WriteLine(myInt.ToString("N", nfi))
' Displays the same value with different groupings.
Dim mySizes1 As Integer() = {2, 3, 4}
Dim mySizes2 As Integer() = {2, 3, 0}
nfi.NumberGroupSizes = mySizes1
Console.WriteLine(myInt.ToString("N", nfi))
nfi.NumberGroupSizes = mySizes2
Console.WriteLine(myInt.ToString("N", nfi))
End Sub
End Class
輸出:
123,456,789,012,345.00 12,3456,7890,123,45.00 1234567890,123,45.00
示例2: SamplesNumberFormatInfo
' 導入命名空間
Imports System.Globalization
Class SamplesNumberFormatInfo
Public Shared Sub Main()
' Creates a new NumberFormatinfo.
Dim myNfi As New NumberFormatInfo()
' Takes a long value.
Dim myInt As Int64 = 123456789012345
' Displays the value with default formatting.
Console.WriteLine("Default " + ControlChars.Tab + ControlChars.Tab _
+ ":" + ControlChars.Tab + "{0}", myInt.ToString("N", myNfi))
' Displays the value with three elements in the GroupSize array.
myNfi.NumberGroupSizes = New Integer() {2, 3, 4}
Console.WriteLine("Grouping ( {0} )" + ControlChars.Tab + ":" _
+ ControlChars.Tab + "{1}", _
PrintArraySet(myNfi.NumberGroupSizes), myInt.ToString("N", myNfi))
' Displays the value with zero as the last element in the GroupSize array.
myNfi.NumberGroupSizes = New Integer() {2, 4, 0}
Console.WriteLine("Grouping ( {0} )" + ControlChars.Tab + ":" _
+ ControlChars.Tab + "{1}", _
PrintArraySet(myNfi.NumberGroupSizes), myInt.ToString("N", myNfi))
End Sub
Public Shared Function PrintArraySet(myArr() As Integer) As String
Dim myStr As String = Nothing
myStr = myArr(0).ToString()
Dim i As Integer
For i = 1 To myArr.Length - 1
myStr += ", " + myArr(i).ToString()
Next i
Return myStr
End Function
End Class
輸出:
Default : 123,456,789,012,345.00 Grouping ( 2, 3, 4 ) : 12,3456,7890,123,45.00 Grouping ( 2, 4, 0 ) : 123456789,0123,45.00