Код: Выделить всё
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
}
}
Код: Выделить всё
(Color) p.GetValue(c, null)
< /code>
или < /p>
p.GetValue(c, null) as Color
Есть ли способ сделать это, пожалуйста?
Подробнее здесь: https://stackoverflow.com/questions/794 ... n-nullable
Мобильная версия