dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Intermediate
Jan 5, 2004

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


GetAllMembers - Retrieving a hashtable containing all the members in a type

' Return a case-insensitive hashtable containing all the members in a type
' Note: requires Imports System.Reflection
'
' Example:
'    Dim ht As Hashtable = GetAllMembers(GetType(String), False)
'    For Each key As Object In ht.Keys
'        Dim member As MemberInfo = DirectCast(ht(key), MemberInfo)
'        Debug.WriteLine(key.ToString() & " - " & '           
' member.MemberType.ToString())
'    Next

Function GetAllMembers(ByVal type As Type, ByVal includePrivate As Boolean) As _
    Hashtable
    Dim ht As Hashtable = _
        Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable()
    ' decide which members should be retrieved
    Dim flags As BindingFlags = BindingFlags.Instance Or BindingFlags.Static Or _
        BindingFlags.Public
    If includePrivate Then
        flags = flags Or BindingFlags.NonPublic
    End If
    ' move members into the hashtable
    For Each member As MemberInfo In type.GetMembers(flags)
        ' avoid duplicates caused from member overloading
        If Not ht.Contains(member.Name) Then
            ' filter off special methods
            If member.MemberType <> MemberTypes.Method OrElse CType(member, _
                MethodInfo).IsSpecialName = False Then
                ht.Add(member.Name, member)
            End If
        End If
    Next
    Return ht
End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date