So I'm working on a project in C# to get the property name by attribute and its value. I have a collection:
ObservableCollection<Entity> collection = new ObsevableCollection<Entity>();
collection.Add(new Entity { Id = 5, Description = "Pizza" });
collection.Add(new Entity { Id = 2, Description = "Coca cola" });
collection.Add(new Entity { Id = 1, Description = "Broccoli" });
and the entity consists of:
class Entity
{
public int Id { get; set; }
[MyAttribute]
public string Description { get; set; }
// other properties
}
My question is: is it possible to get the specific property within the entity that has the attribute MyAttribute and also its value. This would all be from the objects from collection
.