作者:VB.NET开发
项目:Syste
Public Class TestClass
End Class
Public Class Example
Public Shared Sub Main()
Dim test As New TestClass()
Dim objectsToCompare() As Object = { test, test.ToString(), 123,
123.ToString(), "some text",
"Some Text" }
Dim s As String = "some text"
For Each objectToCompare In objectsToCompare
Try
Dim i As Integer = s.CompareTo(objectToCompare)
Console.WriteLine("Comparing '{0}' with '{1}': {2}",
s, objectToCompare, i)
Catch e As ArgumentException
Console.WriteLine("Bad argument: {0} (type {1})",
objectToCompare,
objectToCompare.GetType().Name)
Console.WriteLine("Exception information: {0}", e)
End Try
Console.WriteLine()
Next
End Sub
End Class
作者:VB程序
项目:Syste
' 导入命名空间
Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Try
CalculateValue()
Catch ex As Exception
Console.WriteLine( "ex.Message:" & ex.Message )
Console.WriteLine( "ex.StackTrace:" & ex.StackTrace )
Console.WriteLine( "ex.ToString:" & ex.ToString )
End Try
End Sub
Shared Private Function CalculateValue() As Integer
Return 1 \ Integer.Parse("0")
End Function
End Class