|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
List all public properties of a Class ?Hi all,
Is there any way to get a list of all the Public properties of a Class ? Something like the GetNames() function returns a list of all the items in an Enumeration. As a simple example, let's take the SystemIcons Class. Say, I want to get a list of all it's Public Properties. Thanks in advance, Regards, Cerebrus. Look at System.Reflection
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflection.asp Show quoteHide quote "Cerebrus" <zorg***@sify.com> wrote in message news:1140935893.808675.284440@j33g2000cwa.googlegroups.com... > Hi all, > > Is there any way to get a list of all the Public properties of a Class > ? > > Something like the GetNames() function returns a list of all the items > in an Enumeration. > > As a simple example, let's take the SystemIcons Class. Say, I want to > get a list of all it's Public Properties. > > Thanks in advance, > > Regards, > > Cerebrus. > Err... could you perhaps point me to a tutorial or an example on the
subject. I'm a bit weak on the subject of Reflection ! ;-) Regards, Cerebrus. I think I got the answer to my original question : (For the benefit of
anyone who doesn't know) Dim myType As Type = GetType(System.Drawing.SystemIcons) Dim myProps() As PropertyInfo = myType.GetProperties(BindingFlags.Public Or BindingFlags.Static) Dim myProp As PropertyInfo For Each myProp In myProps Console.WriteLine("Name: {0}, Type: {1}", myProp.Name, myProp.PropertyType) Next Regards, Cerebrus. Cerebrus,
Did you already look at the objectbrowser, View-> ObjectBrowser and look in the (standard) right pane. I hope this helps Cor "Cerebrus" <zorg***@sify.com> schrieb: <URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/ac8f8da74ab352f4>> Is there any way to get a list of all the Public properties of a Class > ? > > Something like the GetNames() function returns a list of all the items > in an Enumeration. > > As a simple example, let's take the SystemIcons Class. Say, I want to > get a list of all it's Public Properties. Note the 'BindingFlags'. In order to get the shared properties you need to specify 'BindingFlags.Static' instead of 'BindingFlags.Instance'. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
How does the community rate .NET 2005 vs. .NET 2003?
Some thoughts on VB9 Set a text in a RowHeader cell academic version [2003] How to move a menu item to the left?! at run time database connection Moving a project to a different location Using 'Function Keys' In vb.net Newbie... Binary Formatter not suitable accross firewalls |
|||||||||||||||||||||||