471,570 Members | 902 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

Get class information

Hi

I create a struct, or a class and I'd like to know
which are the members available.. by code

something like

pubic class nico
{
public int age;
public int old;
}

and somewhere , i could do something like this
foreach(Members member in nico.Members)
{
member.Value = i;
}

See what I mean ?

Where should I start looking for ?

Nicolas, Toulouse
Jan 13 '06 #1
2 1647
nicolas ETIENNE wrote:
Hi

I create a struct, or a class and I'd like to know
which are the members available.. by code

something like

pubic class nico
{
public int age;
public int old;
}

and somewhere , i could do something like this
foreach(Members member in nico.Members)
{
member.Value = i;
}

See what I mean ?

Where should I start looking for ?


Nico n = new Nico();
PropertyCollection properties = TypeDescriptor.GetProperties(n);

these types are in the System.ComponentModel namespace.
:)

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Jan 13 '06 #2
nicolas ETIENNE wrote:
I create a struct, or a class and I'd like to know
which are the members available.. by code
<snip>
Where should I start looking for ?


You should look in the System.Reflection namespace, and at
Type.GetProperties, Type.GetFields etc.

Jon

Jan 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by E G | last post: by
42 posts views Thread by Dan | last post: by
7 posts views Thread by Göran Tänzer | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.