Getting ALL the properties of an object [duplicate]

You can use reflection.

// Get property array
var properties = GetProperties(some_object);

foreach (var p in properties)
{
    string name = p.Name;
    var value = p.GetValue(some_object, null);
}

private static PropertyInfo[] GetProperties(object obj)
{
    return obj.GetType().GetProperties();
}

However, this still does not solve the problem where you have an object with 1000 properties.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)