本文整理匯總了VB.NET中System.Version.Parse方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Version.Parse方法的具體用法?VB.NET Version.Parse怎麽用?VB.NET Version.Parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Version
的用法示例。
在下文中一共展示了Version.Parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
Dim input As String = "4.0"
ParseVersion(input)
input = "4.0."
ParseVersion(input)
input = "1.1.2"
ParseVersion(input)
input = "1.1.2.01702"
ParseVersion(input)
input = "1.1.2.0702.119"
ParseVersion(input)
input = "1.3.5.2150000000"
ParseVersion(input)
End Sub
Private Sub ParseVersion(input As String)
Try
Dim ver As Version = Version.Parse(input)
Console.WriteLine("Converted '{0} to {1}.", input, ver)
Catch e As ArgumentNullException
Console.WriteLine("Error: String to be parsed is null.")
Catch e As ArgumentOutOfRangeException
Console.WriteLine("Error: Negative value in '{0}'.", input)
Catch e As ArgumentException
Console.WriteLine("Error: Bad number of components in '{0}'.",
input)
Catch e As FormatException
Console.WriteLine("Error: Non-integer value in '{0}'.", input)
Catch e As OverflowException
Console.WriteLine("Error: Number out of range in '{0}'.", input)
End Try
End Sub
End Module
輸出:
Converted '4.0 to 4.0. Error: Non-integer value in '4.0.'. Converted '1.1.2 to 1.1.2. Converted '1.1.2.01702 to 1.1.2.1702. Error: Bad number of components in '1.1.2.0702.119'. Error: Number out of range in '1.3.5.2150000000'.