• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

VB.NET Convert.ToString方法代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Convert.ToString方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Convert.ToString方法的具体用法?VB.NET Convert.ToString怎么用?VB.NET Convert.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Convert的用法示例。



在下文中一共展示了Convert.ToString方法的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: bases

Dim bases() As Integer = { 2, 8, 10, 16}
Dim numbers() As Short = { Int16.MinValue, -13621, -18, 12, 19142, _
                           Int16.MaxValue }

For Each base As Integer In bases
   Console.WriteLine("Base {0} conversion:", base)
   For Each number As Short In numbers
      Console.WriteLine("   {0,-8}  -->  0x{1}", _
                        number, Convert.ToString(number, base))
   Next
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:11,代码来源:Convert.ToString

输出:

Base 2 conversion:
-32768    -->  0x1000000000000000
-13621    -->  0x1100101011001011
-18       -->  0x1111111111101110
12        -->  0x1100
19142     -->  0x100101011000110
32767     -->  0x111111111111111
Base 8 conversion:
-32768    -->  0x100000
-13621    -->  0x145313
-18       -->  0x177756
12        -->  0x14
19142     -->  0x45306
32767     -->  0x77777
Base 10 conversion:
-32768    -->  0x-32768
-13621    -->  0x-13621
-18       -->  0x-18
12        -->  0x12
19142     -->  0x19142
32767     -->  0x32767
Base 16 conversion:
-32768    -->  0x8000
-13621    -->  0xcacb
-18       -->  0xffee
12        -->  0xc
19142     -->  0x4ac6
32767     -->  0x7fff


示例2: numbers

Dim numbers() As Short = { Int16.MinValue, Int16.MaxValue}
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

For Each number As Short In numbers
   Console.WriteLine("{0,-8}  -->  {1,8}", _
                     Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                     Convert.ToString(number, nfi))
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:10,代码来源:Convert.ToString

输出:

-32768    -->    ~32768
32767     -->     32767


示例3:

Dim number As ULong = UInt64.MaxValue
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

Console.WriteLine("{0,-12}  -->  {1,12}", _
                  Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                  Convert.ToString(number, nfi))
开发者ID:VB.NET开发者,项目名称:System,代码行数:8,代码来源:Convert.ToString

输出:

18446744073709551615  -->  18446744073709551615


示例4: numbers

' Define an array of numbers to display.
Dim numbers() As Decimal = { 1734231911290.16d, -17394.32921d, _
                             3193.23d, 98012368321.684d }
' Define the culture names used to display them.
Dim cultureNames() As String = { "en-US", "fr-FR", "ja-JP", "ru-RU" }

For Each number As Decimal In numbers
   Console.WriteLine("{0}:", Convert.ToString(number, _
                             System.Globalization.CultureInfo.InvariantCulture))
   For Each cultureName As String In cultureNames
      Dim culture As New System.Globalization.CultureInfo(cultureName)
      Console.WriteLine("   {0}: {1,20}", _
                        culture.Name, Convert.ToString(number, culture))
   Next
   Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:16,代码来源:Convert.ToString

输出:

1734231911290.16:
en-US:     1734231911290.16
fr-FR:     1734231911290,16
ja-JP:     1734231911290.16
ru-RU:     1734231911290,16

-17394.32921:
en-US:         -17394.32921
fr-FR:         -17394,32921
ja-JP:         -17394.32921
ru-RU:         -17394,32921

3193.23:
en-US:              3193.23
fr-FR:              3193,23
ja-JP:              3193.23
ru-RU:              3193,23

98012368321.684:
en-US:      98012368321.684
fr-FR:      98012368321,684
ja-JP:      98012368321.684
ru-RU:      98012368321,684


示例5: cultureNames

' Specify the date to be formatted using various cultures.
Dim tDate As New Date(2010, 4, 15, 20, 30, 40, 333)
' Specify the cultures.
Dim cultureNames() As String = { "en-US", "es-AR", "fr-FR", "hi-IN", _
                                 "ja-JP", "nl-NL", "ru-RU", "ur-PK" }

Console.WriteLine("Converting the date {0}: ", _
                  Convert.ToString(tDate, _
                          System.Globalization.CultureInfo.InvariantCulture))

For Each cultureName As String In CultureNames
   Dim culture As New System.Globalization.CultureInfo(cultureName)
   Dim dateString As String = Convert.ToString(tDate, culture)
   Console.WriteLine("   {0}:  {1,-12}", _
                     culture.Name, dateString)
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:16,代码来源:Convert.ToString

输出:

Converting the date 04/15/2010 20:30:40:
en-US:  4/15/2010 8:30:40 PM
es-AR:  15/04/2010 08:30:40 p.m.
fr-FR:  15/04/2010 20:30:40
hi-IN:  15-04-2010 20:30:40
ja-JP:  2010/04/15 20:30:40
nl-NL:  15-4-2010 20:30:40
ru-RU:  15.04.2010 20:30:40
ur-PK:  15/04/2010 8:30:40 PM


示例6: numbers

Dim numbers() As Integer = { Int32.MinValue, Int32.MaxValue}
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

For Each number As Integer In numbers
   Console.WriteLine("{0,-12}  -->  {1,12}", _
                     Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                     Convert.ToString(number, nfi))
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:10,代码来源:Convert.ToString

输出:

-2147483648  -->  ~2147483648
2147483647   -->  2147483647


示例7: numbers

' Define an array of numbers to display.
Dim numbers() As Double = { -1.5345e16, -123.4321, 19092.123, _
                            1.1734231911290e16 }
' Define the culture names used to display them.
Dim cultureNames() As String = { "en-US", "fr-FR", "ja-JP", "ru-RU" }

For Each number As Double In numbers
   Console.WriteLine("{0}:", Convert.ToString(number, _
                             System.Globalization.CultureInfo.InvariantCulture))
   For Each cultureName As String In cultureNames
      Dim culture As New System.Globalization.CultureInfo(cultureName)
      Console.WriteLine("   {0}: {1,20}", _
                        culture.Name, Convert.ToString(number, culture))
   Next
   Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:16,代码来源:Convert.ToString

输出:

-1.5345E+16:
en-US:          -1.5345E+16
fr-FR:          -1,5345E+16
ja-JP:          -1.5345E+16
ru-RU:          -1,5345E+16

-123.4321:
en-US:            -123.4321
fr-FR:            -123,4321
ja-JP:            -123.4321
ru-RU:            -123,4321

19092.123:
en-US:            19092.123
fr-FR:            19092,123
ja-JP:            19092.123
ru-RU:            19092,123

1.173423191129E+16:
en-US:   1.173423191129E+16
fr-FR:   1,173423191129E+16
ja-JP:   1.173423191129E+16
ru-RU:   1,173423191129E+16


示例8: bases

Dim bases() As Integer = { 2, 8, 10, 16}
Dim numbers() As Integer = { Int32.MinValue, -19327543, -13621, -18, 12, _
                             19142, Int32.MaxValue }

For Each base As Integer In bases
   Console.WriteLine("Base {0} conversion:", base)
   For Each number As Integer In numbers
      Console.WriteLine("   {0,-15}  -->  0x{1}", _
                        number, Convert.ToString(number, base))
   Next
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:11,代码来源:Convert.ToString

输出:

Base 2 conversion:
-2147483648      -->  0x10000000000000000000000000000000
-19327543        -->  0x11111110110110010001010111001001
-13621           -->  0x11111111111111111100101011001011
-18              -->  0x11111111111111111111111111101110
12               -->  0x1100
19142            -->  0x100101011000110
2147483647       -->  0x1111111111111111111111111111111
Base 8 conversion:
-2147483648      -->  0x20000000000
-19327543        -->  0x37666212711
-13621           -->  0x37777745313
-18              -->  0x37777777756
12               -->  0x14
19142            -->  0x45306
2147483647       -->  0x17777777777
Base 10 conversion:
-2147483648      -->  0x-2147483648
-19327543        -->  0x-19327543
-13621           -->  0x-13621
-18              -->  0x-18
12               -->  0x12
19142            -->  0x19142
2147483647       -->  0x2147483647
Base 16 conversion:
-2147483648      -->  0x80000000
-19327543        -->  0xfed915c9
-13621           -->  0xffffcacb
-18              -->  0xffffffee
12               -->  0xc
19142            -->  0x4ac6
2147483647       -->  0x7fffffff


示例9: numbers

Dim numbers() As SByte = { SByte.MinValue, -12, 17, SByte.MaxValue}
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"
For Each number As SByte In numbers
   Console.WriteLine(Convert.ToString(number, nfi))
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:7,代码来源:Convert.ToString

输出:

~128
~12
17
127


示例10: bases

Dim bases() As Integer = { 2, 8, 10, 16}
Dim numbers() As Long = { Int64.MinValue, -193275430, -13621, -18, 12, _
                             1914206117, Int64.MaxValue }

For Each base As Integer In bases
   Console.WriteLine("Base {0} conversion:", base)
   For Each number As Long In numbers
      Console.WriteLine("   {0,-23}  -->  0x{1}", _
                        number, Convert.ToString(number, base))
   Next
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:11,代码来源:Convert.ToString

输出:

Base 2 conversion:
-9223372036854775808     -->  0x1000000000000000000000000000000000000000000000000000000000000000
-193275430               -->  0x1111111111111111111111111111111111110100011110101101100111011010
-13621                   -->  0x1111111111111111111111111111111111111111111111111100101011001011
-18                      -->  0x1111111111111111111111111111111111111111111111111111111111101110
12                       -->  0x1100
1914206117               -->  0x1110010000110000111011110100101
9223372036854775807      -->  0x111111111111111111111111111111111111111111111111111111111111111
Base 8 conversion:
-9223372036854775808     -->  0x1000000000000000000000
-193275430               -->  0x1777777777776436554732
-13621                   -->  0x1777777777777777745313
-18                      -->  0x1777777777777777777756
12                       -->  0x14
1914206117               -->  0x16206073645
9223372036854775807      -->  0x777777777777777777777
Base 10 conversion:
-9223372036854775808     -->  0x-9223372036854775808
-193275430               -->  0x-193275430
-13621                   -->  0x-13621
-18                      -->  0x-18
12                       -->  0x12
1914206117               -->  0x1914206117
9223372036854775807      -->  0x9223372036854775807
Base 16 conversion:
-9223372036854775808     -->  0x8000000000000000
-193275430               -->  0xfffffffff47ad9da
-13621                   -->  0xffffffffffffcacb
-18                      -->  0xffffffffffffffee
12                       -->  0xc
1914206117               -->  0x721877a5
9223372036854775807      -->  0x7fffffffffffffff


示例11: Example

Public Class Temperature 
   Private m_Temp As Decimal

   Public Sub New(temperature As Decimal)
      Me.m_Temp = temperature
   End Sub
   
   Public ReadOnly Property Celsius() As Decimal
      Get
         Return Me.m_Temp
      End Get   
   End Property
   
   Public ReadOnly Property Kelvin() As Decimal
      Get
         Return Me.m_Temp + 273.15d   
      End Get
   End Property
   
   Public ReadOnly Property Fahrenheit() As Decimal
      Get
         Return Math.Round(CDec(Me.m_Temp * 9 / 5 + 32), 2)
      End Get      
   End Property
   
   Public Overrides Function ToString() As String
      Return m_Temp.ToString("N2") & " °C"
   End Function
End Class

Module Example
   Public Sub Main()
      Dim cold As New Temperature(-40)
      Dim freezing As New Temperature(0)
      Dim boiling As New Temperature(100)
      
      Console.WriteLine(Convert.ToString(cold, Nothing))
      Console.WriteLine(Convert.ToString(freezing, Nothing))
      Console.WriteLine(Convert.ToString(boiling, Nothing))
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:41,代码来源:Convert.ToString

输出:

-40.00 °C
0.00 °C
100.00 °C


示例12: Example

Public Class Temperature : Implements IFormattable 
   Private m_Temp As Decimal 

   Public Sub New(temperature As Decimal)
      Me.m_Temp = temperature
   End Sub 

   Public ReadOnly Property Celsius As Decimal 
      Get 
         Return Me.m_Temp
      End Get    
   End Property 

   Public ReadOnly Property Kelvin As Decimal 
      Get 
         Return Me.m_Temp + 273.15d   
      End Get 
   End Property 

   Public ReadOnly Property Fahrenheit As Decimal 
      Get 
         Return Math.Round(CDec(Me.m_Temp * 9 / 5 + 32), 2)
      End Get       
   End Property 

   Public Overrides Function ToString() As String 
      Return ToString("G", Nothing) 
   End Function 
   
   Public Overloads Function ToString(fmt As String, 
                                      provider As IFormatProvider) As String _
                             Implements IFormattable.ToString
      Dim formatter As TemperatureProvider = Nothing
      If provider IsNot Nothing Then formatter = TryCast(provider.GetFormat(GetType(TemperatureProvider)),
                                                         TemperatureProvider)

      If String.IsNullOrWhiteSpace(fmt) Then
         If formatter IsNot Nothing Then
            fmt = formatter.Format
         Else
            fmt = "G"
         End If
      End If

      Select Case fmt.ToUpper()
         Case "G", "C"
            Return m_Temp.ToString("N2") & " °C" 
         Case "F"
            Return Fahrenheit.ToString("N2") + " °F"
         Case "K"
            Return Kelvin.ToString("N2") + " K"
         Case Else
            Throw New FormatException(String.Format("'{0}' is not a valid format specifier.", fmt))
      End Select
   End Function                             
End Class 

Public Class TemperatureProvider : Implements IFormatProvider
   Private fmtStrings() As String = { "C", "G", "F", "K" }
   Private rnd As New Random()
   
   Public Function GetFormat(formatType As Type) As Object _
                   Implements IFormatProvider.GetFormat 
      Return Me 
   End Function
   
   Public ReadOnly Property Format As String
      Get
         Return fmtStrings(rnd.Next(0, fmtStrings.Length))
      End Get
   End Property
End Class

Module Example
   Public Sub Main()
      Dim cold As New Temperature(-40)
      Dim freezing As New Temperature(0)
      Dim boiling As New Temperature(100)

      Dim tp As New TemperatureProvider()
      
      Console.WriteLine(Convert.ToString(cold, tp))
      Console.WriteLine(Convert.ToString(freezing, tp))
      Console.WriteLine(Convert.ToString(boiling, tp))
   End Sub 
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:86,代码来源:Convert.ToString

输出:

-40.00 °C
273.15 K
100.00 °C


示例13: numbers

' Define an array of numbers to display.
Dim numbers() As Single = { -1.5345e16, -123.4321, 19092.123, _
                            1.1734231911290e16 }
' Define the culture names used to display them.
Dim cultureNames() As String = { "en-US", "fr-FR", "ja-JP", "ru-RU" }

For Each number As Single In numbers
   Console.WriteLine("{0}:", Convert.ToString(number, _
                             System.Globalization.CultureInfo.InvariantCulture))
   For Each cultureName As String In cultureNames
      Dim culture As New System.Globalization.CultureInfo(cultureName)
      Console.WriteLine("   {0}: {1,20}", _
                        culture.Name, Convert.ToString(number, culture))
   Next
   Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:16,代码来源:Convert.ToString

输出:

-1.5345E+16:
en-US:          -1.5345E+16
fr-FR:          -1,5345E+16
ja-JP:          -1.5345E+16
ru-RU:          -1,5345E+16

-123.4321:
en-US:            -123.4321
fr-FR:            -123,4321
ja-JP:            -123.4321
ru-RU:            -123,4321

19092.123:
en-US:            19092.123
fr-FR:            19092,123
ja-JP:            19092.123
ru-RU:            19092,123

1.173423191129E+16:
en-US:   1.173423191129E+16
fr-FR:   1,173423191129E+16
ja-JP:   1.173423191129E+16
ru-RU:   1,173423191129E+16


示例14: DummyProvider

' Example of Convert.ToString( non-numeric types, IFormatProvider ).
Imports System.Globalization

' An instance of this class can be passed to methods that require 
' an IFormatProvider.
Public Class DummyProvider
    Implements IFormatProvider

    ' Normally, GetFormat returns an object of the requested type
    ' (usually itself) if it is able; otherwise, it returns Nothing. 
    Public Function GetFormat( argType As Type ) As Object _
        Implements IFormatProvider.GetFormat

        ' Here, the type of argType is displayed, and GetFormat
        ' always returns Nothing.
        Console.Write( "{0,-40}", argType.ToString( ) )
        Return Nothing

    End Function 
End Class

Module ConvertNonNumericProviderDemo

    Sub Main( )

        ' Create an instance of the IFormatProvider.
        Dim provider    As New DummyProvider( )
        Dim converted   As String

        ' Convert these values using DummyProvider.
        Dim Int32A      As Integer  = -252645135   
        Dim DoubleA     As Double   = 61680.3855
        Dim ObjDouble   As Object   = CType( -98765.4321, Object )
        Dim DayTimeA    As DateTime = _
                            new DateTime( 2001, 9, 11, 13, 45, 0 )

        Dim BoolA       As Boolean  = True
        Dim StringA     As String   = "Qwerty"
        Dim CharA       As Char     = "$"c
        Dim TSpanA      As TimeSpan = New TimeSpan( 0, 18, 0 )
        Dim ObjOther    As Object   = CType( provider, Object )

        Console.WriteLine( "This example of " & _
            "Convert.ToString( non-numeric, IFormatProvider ) " & _
            vbCrLf & "generates the following output. The " & _
            "provider type, argument type, " & vbCrLf & "and " & _
            "argument value are displayed." )
        Console.WriteLine( vbCrLf & _
            "Note: The IFormatProvider object is not called for " & _
            "Boolean, String, " & vbCrLf & "Char, TimeSpan, " & _
            "and non-numeric Object." )

        ' The format provider is called for these conversions.
        Console.WriteLine( )
        converted =  Convert.ToString( Int32A, provider )
        Console.WriteLine( "Int32    {0}", converted )
        converted =  Convert.ToString( DoubleA, provider )
        Console.WriteLine( "Double   {0}", converted )
        converted =  Convert.ToString( ObjDouble, provider )
        Console.WriteLine( "Object   {0}", converted )
        converted =  Convert.ToString( DayTimeA, provider )
        Console.WriteLine( "DateTime {0}", converted )

        ' The format provider is not called for these conversions.
        Console.WriteLine( )
        converted =  Convert.ToString( BoolA, provider )
        Console.WriteLine( "Boolean  {0}", converted )
        converted =  Convert.ToString( StringA, provider )
        Console.WriteLine( "String   {0}", converted )
        converted =  Convert.ToString( CharA, provider )
        Console.WriteLine( "Char     {0}", converted )
        converted =  Convert.ToString( TSpanA, provider )
        Console.WriteLine( "TimeSpan {0}", converted )
        converted =  Convert.ToString( ObjOther, provider )
        Console.WriteLine( "Object   {0}", converted )

    End Sub
End Module

' This example of Convert.ToString( non-numeric, IFormatProvider )
' generates the following output. The provider type, argument type,
' and argument value are displayed.
'
' Note: The IFormatProvider object is not called for Boolean, String,
' Char, TimeSpan, and non-numeric Object.
' 
' System.Globalization.NumberFormatInfo   Int32    -252645135
' System.Globalization.NumberFormatInfo   Double   61680.3855
' System.Globalization.NumberFormatInfo   Object   -98765.4321
' System.Globalization.DateTimeFormatInfo DateTime 9/11/2001 1:45:00 PM
' 
' Boolean  True
' String   Qwerty
' Char     $
' TimeSpan 00:18:00
' Object   DummyProvider
开发者ID:VB.NET开发者,项目名称:System,代码行数:96,代码来源:Convert.ToString


示例15:

Dim number As UShort = UInt16.MaxValue
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

Console.WriteLine("{0,-6}  -->  {1,6}", _
                  Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                  Convert.ToString(number, nfi))
开发者ID:VB.NET开发者,项目名称:System,代码行数:8,代码来源:Convert.ToString

输出:

65535   -->   65535


示例16:

Dim number As UInteger = UInt32.MaxValue
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

Console.WriteLine("{0,-8}  -->  {1,8}", _
                  Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                  Convert.ToString(number, nfi))
开发者ID:VB.NET开发者,项目名称:System,代码行数:8,代码来源:Convert.ToString

输出:

4294967295  -->  4294967295


示例17: numbers

Dim numbers() As Long = { CLng(Int32.MinValue) * 2, CLng(Int32.MaxValue) * 2 }
Dim nfi As New System.Globalization.NumberFormatInfo()
nfi.NegativeSign = "~"
nfi.PositiveSign = "!"

For Each number As Long In numbers
   Console.WriteLine("{0,-12}  -->  {1,12}", _
                     Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), _
                     Convert.ToString(number, nfi))
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:10,代码来源:Convert.ToString

输出:

-4294967296  -->  ~4294967296
4294967294   -->  4294967294


示例18: bases

Dim bases() As Integer = { 2, 8, 10, 16}
Dim numbers() As Byte = { Byte.MinValue, 12, 103, Byte.MaxValue}

For Each base As Integer In bases
   Console.WriteLine("Base {0} conversion:", base)
   For Each number As Byte In numbers
      Console.WriteLine("   {0,-5}  -->  0x{1}", _
                        number, Convert.ToString(number, base))
   Next
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:10,代码来源:Convert.ToString

输出:

Base 2 conversion:
0      -->  0x0
12     -->  0x1100
103    -->  0x1100111
255    -->  0x11111111
Base 8 conversion:
0      -->  0x0
12     -->  0x14
103    -->  0x147
255    -->  0x377
Base 10 conversion:
0      -->  0x0
12     -->  0x12
103    -->  0x103
255    -->  0x255
Base 16 conversion:
0      -->  0x0
12     -->  0xc
103    -->  0x67
255    -->  0xff


示例19: numbers

Dim numbers() As ULong = { UInt64.MinValue, 1031, 189045, UInt64.MaxValue }
Dim result As String

For Each number As ULong In numbers
   result = Convert.ToString(number)
   Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
                        number.GetType().Name, number, _
                        result.GetType().Name, result)
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:9,代码来源:Convert.ToString

输出:

Converted the UInt64 value 0 to the String value 0.
Converted the UInt64 value 1031 to the String value 1031.
Converted the UInt64 value 189045 to the String value 189045.
Converted the UInt64 value 18446744073709551615 to the String value 18446744073709551615.


示例20: numbers

' Define an array of numbers to display.
Dim numbers() As Byte = { 12, 100, Byte.MaxValue }
' Define the culture names used to display them.
Dim cultureNames() As String = { "en-US", "fr-FR" }

For Each number As Byte In numbers
   Console.WriteLine("{0}:", Convert.ToString(number, _
                             System.Globalization.CultureInfo.InvariantCulture))
   For Each cultureName As String In cultureNames
      Dim culture As New System.Globalization.CultureInfo(cultureName)
      Console.WriteLine("   {0}: {1,20}", _
                        culture.Name, Convert.ToString(number, culture))
   Next
   Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:15,代码来源:Convert.ToString

输出:

12:
en-US:                   12
fr-FR:                   12

100:
en-US:                  100
fr-FR:                  100

255:
en-US:                  255
fr-FR:                  255



注:本文中的System.Convert.ToString方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET Convert.ToUInt16方法代码示例发布时间:2022-05-24
下一篇:
VB.NET Convert.ToSingle方法代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap