Code: Select all
var properties = c.GetType().GetProperties();
// note that c is a System.Windows.Forms.Control
foreach( var p in properties )
{
if (p.PropertyType.Name.Contains("Color") )
{
var colour_value = p.GetValue(c,null);
// I need to cast colour_value to a Color
}
}
Code: Select all
(Color) p.GetValue(c, null)
< /code>
oder < /p>
p.GetValue(c, null) as Color
Gibt es eine Möglichkeit, dies zu tun, bitte?