close
'要將數值轉換成字串,有二種方法。一種是用資料類型的ToString()來做,另一種則是以Convert類別的ToString()來做。
Module Module1
Sub Main()
Dim i As Integer = 789
'將整數轉換字串
Dim s1 As String = i.ToString()
Dim s2 As String = Convert.ToString(i)
'輸出結果
Console.WriteLine("i={0}, s1={1}, s2={2}", i, s1, s2)
Dim d As Double = 123.89
'將實數轉換字串
Dim s3 As String = d.ToString()
Dim s4 As String = Convert.ToString(d)
'輸出結果
Console.WriteLine("d={0}, s3={1}, s4={2}", d, s3, s4)
End Sub
End Module
Module Module1
Sub Main()
Dim i As Integer = 789
'將整數轉換字串
Dim s1 As String = i.ToString()
Dim s2 As String = Convert.ToString(i)
'輸出結果
Console.WriteLine("i={0}, s1={1}, s2={2}", i, s1, s2)
Dim d As Double = 123.89
'將實數轉換字串
Dim s3 As String = d.ToString()
Dim s4 As String = Convert.ToString(d)
'輸出結果
Console.WriteLine("d={0}, s3={1}, s4={2}", d, s3, s4)
End Sub
End Module
全站熱搜
留言列表