Get all properties which marked certain attribute

It’s probably easiest to use IsDefined:

var properties = type.GetProperties()
    .Where(prop => prop.IsDefined(typeof(LocalizedDisplayNameAttribute), false));

To get the values themselves, you’d use:

var attributes = (LocalizedDisplayNameAttribute[]) 
      prop.GetCustomAttributes(typeof(LocalizedDisplayNameAttribute), false);

Leave a Comment