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


VB.NET Type.GetInterfaces方法代码示例

本文整理汇总了VB.NET中System.Type.GetInterfaces方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Type.GetInterfaces方法的具体用法?VB.NET Type.GetInterfaces怎么用?VB.NET Type.GetInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Type的用法示例。


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

示例1: Example

' 导入命名空间
Imports System.Collections.Generic

Public Class Example

    Shared Sub Main()

        Console.WriteLine(vbCrLf & _
            "Interfaces implemented by Dictionary(Of Integer, String):" & vbCrLf)
        
        For Each tinterface As Type In GetType(Dictionary(Of Integer, String)).GetInterfaces()

            Console.WriteLine(tinterface.ToString())

        Next

        'Console.ReadLine()      ' Uncomment this line for Visual Studio. 
    End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:19,代码来源:Type.GetInterfaces

输出:

Interfaces implemented by Dictionary(Of Integer, String):
System.Collections.Generic.IDictionary`2[System.Int32,System.String]
System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collection.IEnumerable
System.Collection.IDictionary
System.Collection.ICollection
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.IDeserializationCallback

示例2: Type.GetInterfaces()

' 导入命名空间
Imports System.Reflection


Public Class MainClass

   Public Shared Sub Main()
        Dim Book = New Derived()

        Dim Member As MemberInfo
        Console.WriteLine("Members:")
        For Each Member In Book.GetType.GetMembers()
            Console.WriteLine(Member.Name & " " & Member.MemberType)
        Next

        Dim PropertyObj As PropertyInfo
        Console.WriteLine("Properties:")
        For Each PropertyObj In Book.GetType.GetProperties()
            Console.WriteLine(PropertyObj.Name & " " & PropertyObj.PropertyType.ToString())
        Next

        Dim MethodObj As MethodInfo
        Console.WriteLine("Methods:")
        For Each MethodObj In Book.GetType.GetMethods()
            Console.WriteLine(MethodObj.Name & " " & MethodObj.ReturnType.ToString())
        Next

        Dim EventObj As EventInfo
        Console.WriteLine("Events:")
        For Each EventObj In Book.GetType.GetEvents()
            Console.WriteLine(EventObj.Name & " " & EventObj.IsMulticast)
        Next

        Dim InterfaceObj As Type
        Console.WriteLine("Events:")
        For Each InterfaceObj In Book.GetType.GetInterfaces()
            Console.WriteLine(InterfaceObj.Name)
        Next

   
   End Sub

End Class 
    Class Base
        Public ProductID As String
        Public Weight As Double
        Private ProductPrice As Double

        Public Sub New()
        End Sub

        Public ReadOnly Property Price() As Double
            Get
                Return 0
            End Get
        End Property

    End Class

    Class Derived
        Inherits Base
        Implements IFormattable

        Public Title As String
        Public Author As String
        Public Publisher As String

        Public Overridable Overloads Function ToString(ByVal _
          Format As String, ByVal Provider As IFormatProvider) _
          As String Implements IFormattable.ToString

            ToString = Title

        End Function

        Public Sub New()
            MyBase.New()

        End Sub

    End Class
开发者ID:VB程序员,项目名称:System,代码行数:81,代码来源:Type.GetInterfaces


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