jeudi 29 avril 2021

PropertyInfo parameter with requirements

Is it possible to take PropertyInfo (or something similar) as an argument and also require that the PropertyInfo be of type decimal? Or better yet require that it be a property of a specific class or interface? I'm thinking similar to how typescript has keyof

This is what I was hoping would work

public decimal SumProperty(Item item, PropertyInfo propertyOfItem){
    // has to be casted to decimal?
    return propertyOfItem.GetValue(item);
}




Aucun commentaire:

Enregistrer un commentaire