当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET MethodBase.IsHideBySig属性代码示例

本文整理汇总了VB.NET中System.Reflection.MethodBase.IsHideBySig属性的典型用法代码示例。如果您正苦于以下问题:VB.NET MethodBase.IsHideBySig属性的具体用法?VB.NET MethodBase.IsHideBySig怎么用?VB.NET MethodBase.IsHideBySig使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。


在下文中一共展示了MethodBase.IsHideBySig属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Test

' 导入命名空间
Imports System.Reflection

' The base class B contains an overloaded method M.
'
Public Class B
    Public Overridable Sub M()
        Console.WriteLine("B's M()")
    End Sub
    Public Overridable Sub M(ByVal x As Integer)
        Console.WriteLine("B's M({0})", x)
    End Sub
End Class

' The derived class D hides the inherited method M.
'
Public Class D
    Inherits B
    Shadows Public Sub M(ByVal i As Integer)
        Console.WriteLine("D's M({0})", i)
    End Sub
End Class

Public Class Test
    Public Shared Sub Main()
        Dim dinst As New D()
        ' In Visual Basic, the method in the derived class hides by
        ' name, rather than by signature.  Thus, although a list of all the 
        ' overloads of M shows three overloads, only one can be called from
        ' class D.  
        '
        Console.WriteLine("------ List the overloads of M in the derived class D ------")
        Dim t As Type = dinst.GetType()
        For Each minfo As MethodInfo In t.GetMethods()
            If minfo.Name = "M" Then Console.WriteLine( _
                "Overload of M: {0}  IsHideBySig = {1}, DeclaringType = {2}", _
                minfo, minfo.IsHideBySig, minfo.DeclaringType)
        Next

        ' The method M in the derived class hides the method in B.
        '
        Console.WriteLine("------ Call the overloads of M available in D ------")
        ' The following line causes a compile error, because both overloads
        ' in the base class are hidden.  Contrast this with C#, where only 
        ' one of the overloads of B would be hidden.
        'dinst.M()
        dinst.M(42)
        
        ' If D is cast to the base type B, both overloads of the 
        ' shadowed method can be called.
        '
        Console.WriteLine("------ Call the shadowed overloads of M ------")
        Dim binst As B = dinst
        binst.M()
        binst.M(42)         
    End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Reflection,代码行数:57,代码来源:MethodBase.IsHideBySig

输出:

------ List the overloads of M in the derived class D ------
Overload of M: Void M(Int32)  IsHideBySig = False, DeclaringType = B
Overload of M: Void M()  IsHideBySig = False, DeclaringType = B
Overload of M: Void M(Int32)  IsHideBySig = False, DeclaringType = D
------ Call the overloads of M available in D ------
D's M(42)
------ Call the shadowed overloads of M ------
B's M()
B's M(42)


注:本文中的System.Reflection.MethodBase.IsHideBySig属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。