Solved

howto get displayname attribute of an property in a class

Posted on 2007-12-04
1
1,342 Views
Last Modified: 2013-11-25
public class MyClass
    <DisplayName("ISO-code")> _
    Public  Property IsoCode() As String
0
Comment
Question by:ecapro
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 125 total points
ID: 20402462
try with this:

            Dim DisplayName as String
           ' Get the type of MyClass1.
            Dim myType as Type = TypeOf(MyClass1)
            ' Get the property info
            Dim pop as PropertyInfo = myType.GetProperty("DisplayName")
            ' Get attribute list
            Dim attrs() as Object = prop.GetCustomAttribues(TypeOf(DisplayNameAttribute), False)
            ' check if attribute exists
            If attrs.Length > 0
                   DisplayName = DirectCast(attrs(0), DisplayNameAttribute).DisplayName
                   
           
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now