⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 latebindingtests2.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
    Class C402        Public Function fun(ByVal i1 As Integer, ByVal i2 As Long, ByVal ParamArray a() As Long)            Return 10        End Function        Public Function fun(ByVal i1 As Integer, ByVal ParamArray a() As Long)            Return 20        End Function    End Class#If NET_2_0 Then    'TargetJvmNotWorking - Ambiguous matching in method resolution    <Category("TargetJvmNotWorking")> _    <Test()> _    Public Sub LateBind_TypeMembersM_2()#Else    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_TypeMembersM_2()#End If        Dim o As Object = New C402        o.fun(1, 2, 3)    End Sub#If NET_2_0 Then    'TargetJvmNotWorking - Ambiguous matching in method resolution    <Category("TargetJvmNotWorking")> _    <Test()> _    Public Sub LateBind_TypeMembersM_3()#Else    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_TypeMembersM_3()#End If        Dim o As Object = New C402        o.fun(1, 2)    End Sub    Class C403        Public Function fun(ByVal i1 As Short, ByVal i2 As Integer, ByVal ParamArray a() As Long)            Return 10        End Function        Public Function fun(ByVal i1 As Short, ByVal ParamArray a() As Long)            Return 20        End Function    End Class    <Test()> _    Public Sub LateBind_TypeMembersM_4()        Dim o As Object = New C403        Dim sh As Short = 2        Assert.AreEqual(10, o.fun(sh, sh, sh))    End Sub    Class C500        Sub fun(ByRef a As Long)            a = a + 10        End Sub        Sub fun(ByRef a As Integer)            a = a + 20        End Sub        Sub fun(ByRef a As Decimal)            a = a + 30        End Sub    End Class    <Test()> _    Public Sub LateBind_TypeMembersF()        Dim a As Integer = 10        Dim a1 As Long = 10        Dim a2 As Decimal = 10        Dim o As Object = New C500        o.fun(a)        o.fun(a1)        o.fun(a2)        Assert.AreEqual(30, a)        Assert.AreEqual(20, a1)        Assert.AreEqual(40, a2)    End Sub    Class C800        Public Function fun(ByVal i As Integer, ByVal a As Long)            If i = 2 And a = 1 Then                Return 10            End If            Return 11        End Function    End Class    <Test()> _    Public Sub LateBind_TypeMembersU()        Dim o As Object = New C800        Dim a As Integer = o.fun(a:=1, i:=2)        Assert.AreEqual(10, a)    End Sub    Class C700        Public b As Byte    End Class    <Test()> _    Public Sub LateBind_TypeMembersY()        Dim o As Object = New C700        o.b = 0        Assert.AreEqual(0, o.b)    End Sub    Private Class C900        Public Function F(ByVal ParamArray arr() As Integer) As String            Return "ParamArray Integer()"        End Function        Public Function F(ByVal ParamArray arr() As Long) As String            Return "ParamArray Long()"        End Function    End Class    <Test()> _    Public Sub LateBind_TypeMembers_2()        Dim o As Object = New C900        Dim i As Integer = 5        Dim l As Long = 7        Dim sh As Short = 3        Assert.AreEqual("ParamArray Integer()", o.F(i, i, i, i, i))        Assert.AreEqual("ParamArray Long()", o.F(l, l, l, l, l, l))        Assert.AreEqual("ParamArray Integer()", o.F(sh, sh, sh, sh))    End Sub    Private Class C1000        Public Function F(ByVal i As Integer)            Return "Integer"        End Function        Public Function F(ByVal i As Long)            Return "Long"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_1()        Dim o As Object = New C1000        Assert.AreEqual("Integer", o.F(Nothing))    End Sub    Private Class C1001        Public Function F(ByVal i As Integer)            Return "Integer"        End Function        Public Function F(ByVal i As Boolean)            Return "Boolean"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_2()        Dim o As Object = New C1001        o.F(Nothing)    End Sub    Private Class C1002        Public Function F(ByVal i As Integer)            Return "Integer"        End Function        Public Function F(ByVal i As Byte)            Return "Byte"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_3()        Dim o As Object = New C1002        Assert.AreEqual("Byte", o.F(Nothing))    End Sub    Private Class C1003        Public Function F(ByVal i As Integer)            Return "Integer"        End Function        Public Function F(ByVal i As Char)            Return "Char"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_4()        Dim o As Object = New C1003        o.F(Nothing)    End Sub    Private Class C1004        Public Function F(ByVal i As Integer)            Return "Integer"        End Function        Public Function F(ByVal i As String)            Return "String"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_5()        Dim o As Object = New C1004        o.F(Nothing)    End Sub    Private Class C1005        Public Function F(ByVal i As Char)            Return "Char"        End Function        Public Function F(ByVal i As String)            Return "String"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_6()        Dim o As Object = New C1005        Assert.AreEqual("Char", o.F(Nothing))    End Sub    Private Class C1006        Public Function F(ByVal i As Char)            Return "Char"        End Function        Public Function F(ByVal i As Boolean)            Return "Boolean"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_7()        Dim o As Object = New C1006        Assert.AreEqual("Char", o.F(Nothing))    End Sub    Private Class C1007        Public Function F(ByVal i As Boolean)            Return "Boolean"        End Function        Public Function F(ByVal i As String)            Return "String"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_8()        Dim o As Object = New C1007        o.F(Nothing)    End Sub    Private Class C1008        Public Function F(ByVal i As Object)            Return "Object"        End Function        Public Function F(ByVal i As String)            Return "String"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_9()        Dim o As Object = New C1008        Assert.AreEqual("String", o.F(Nothing))    End Sub    Private Class C1009        Public Function F(ByVal i As Object)            Return "Object"        End Function        Public Function F(ByVal i As Char)            Return "Char"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_10()        Dim o As Object = New C1009        Assert.AreEqual("Char", o.F(Nothing))    End Sub    Private Class C1010        Public Function F(ByVal i As Object)            Return "Object"        End Function        Public Function F(ByVal i As Integer)            Return "Integer"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_11()        Dim o As Object = New C1010        Assert.AreEqual("Integer", o.F(Nothing))    End Sub    Private Class C1011        Public Function F(ByVal i As A)            Return "A"        End Function        Public Function F(ByVal i As Integer)            Return "Integer"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Nothing_12()        Dim o As Object = New C1011        o.F(Nothing)    End Sub    Private Class C1012        Public Function F(ByVal i As A)            Return "A"        End Function        Public Function F(ByVal i As BB)            Return "BB"        End Function    End Class    <Test()> _    Public Sub LateBind_Nothing_13()        Dim o As Object = New C1012        Assert.AreEqual("BB", o.F(Nothing))    End Sub#Region "Private Helper Classes"    Private Class A        Public Overrides Function toString() As String            Return "A.instance"        End Function    End Class    Private Class BB        Inherits A        Public Overrides Function toString() As String            Return "BB.instance"        End Function    End Class    Private Class CC        Inherits BB        Public Overrides Function toString() As String            Return "CC.instance"        End Function    End Class    Private Class IC        Implements IConvertible        Public Function GetTypeCode() As System.TypeCode Implements System.IConvertible.GetTypeCode            Return TypeCode.Object        End Function        Public Function ToBoolean(ByVal provider As System.IFormatProvider) As Boolean Implements System.IConvertible.ToBoolean            Return True        End Function        Public Function ToByte(ByVal provider As System.IFormatProvider) As Byte Implements System.IConvertible.ToByte            Return 1        End Function        Public Function ToChar(ByVal provider As System.IFormatProvider) As Char Implements System.IConvertible.ToChar            Return "a"c        End Function        Public Function ToDateTime(ByVal provider As System.IFormatProvider) As Date Implements System.IConvertible.ToDateTime            Return New DateTime        End Function        Public Function ToDecimal(ByVal provider As System.IFormatProvider) As Decimal Implements System.IConvertible.ToDecimal            Return 1        End Function        Public Function ToDouble(ByVal provider As System.IFormatProvider) As Double Implements System.IConvertible.ToDouble            Return 1        End Function        Public Function ToInt16(ByVal provider As System.IFormatProvider) As Short Implements System.IConvertible.ToInt16            Return 1        End Function        Public Function ToInt32(ByVal provider As System.IFormatProvider) As Integer Implements System.IConvertible.ToInt32            Return 1        End Function        Public Function ToInt64(ByVal provider As System.IFormatProvider) As Long Implements System.IConvertible.ToInt64            Return 1        End Function        Public Function ToSByte(ByVal provider As System.IFormatProvider) As SByte Implements System.IConvertible.ToSByte            Return New SByte        End Function        Public Function ToSingle(ByVal provider As System.IFormatProvider) As Single Implements System.IConvertible.ToSingle            Return 1        End Function        Public Overloads Function ToString(ByVal provider As System.IFormatProvider) As String Implements System.IConvertible.ToString            Return "ICOnvertible.instance"        End Function        Public Function ToType(ByVal conversionType As System.Type, ByVal provider As System.IFormatProvider) As Object Implements System.IConvertible.ToType            Return New Object        End Function        Public Function ToUInt16(ByVal provider As System.IFormatProvider) As UInt16 Implements System.IConvertible.ToUInt16            Return New UInt16        End Function        Public Function ToUInt32(ByVal provider As System.IFormatProvider) As UInt32 Implements System.IConvertible.ToUInt32            Return New UInt32        End Function        Public Function ToUInt64(ByVal provider As System.IFormatProvider) As UInt64 Implements System.IConvertible.ToUInt64            Return New UInt64        End Function    End Class#End RegionEnd Class#End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -