Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

howto get displayname attribute of an property in a class

Posted on 2007-12-04
1
Medium Priority
?
1,583 Views
Last Modified: 2013-11-25
public class MyClass
    <DisplayName("ISO-code")> _
    Public  Property IsoCode() As String
0
Comment
Question by:ecapro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 375 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

636 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