[Solved] Find name of member in list

[ad_1]

You can get the values of your properties using Reflection and then use LINQ to get name of the property that has the value of 100:

var userType = typeof(User);
var properties = userType
                .GetProperties()
                .Where(x => x.Name.StartsWith("Value")).ToList();

foreach (var user in LiUsers)
{
    var property  = properties.FirstOrDefault(x => (int)x.GetValue(user) == 100);
    if(property != null)
    {
        string name = property.Name;
    }
}

9

[ad_2]

solved Find name of member in list