本文整理汇总了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'.