You need to make the distinction between attributes applied to the class
and those applied to the class members.
For a class, or more properly a type, you can use GetType().Attributes.
For other members you would go via the TypeDescriptor to obtain the
MemberInfo objects for the members you were interested in such as
properties, fields and methods.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
s.******@gmail.com wrote:
Hello everybody,
Trying to get all attributes from a class (class1), I got them through
properties, is it a simple way to get all class atributes not using
their properties??
public void GetAllClassAttributes()
{
Type classType = class1.GetType();
PropertyInfo[] a_pi= classType.GetProperties();
foreach ( PropertyInfo pi in a_pi)
{
if ( pi.CanRead ) pi.GetValue(resumen, null).ToString();
}
Console.Read();
}