The following code snippet returns an array of PropertyInfo
objects that have a defined attribute:
var props = t.GetProperties().Where(
prop => Attribute.IsDefined(prop, typeof(MyAttribute)));
.
.
How can I do the same thing in .NET2.0, and therefore without using Linq?
try
List<PropertyInfo> props = new List<PropertyInfo> ();
foreach (PropertyInfo prop in t.GetProperties())
{
if ( Attribute.IsDefined(prop, typeof(MyAttribute)) )
props.Add (prop);
}