Exemple #1
0
 static NamedBrush()
 {
     PropertyInfo[] props = typeof(Brushes).GetProperties();
     nbrushes = new NamedBrush[props.Length];
     for (int i = 0; i < props.Length; i++)
         nbrushes[i] = new NamedBrush(props[i].Name, (Brush)props[i].GetValue(null, null));
 }
Exemple #2
0
 static NamedBrush()
 {
     PropertyInfo[] props = typeof(Brushes).GetProperties();
     nbrushes = new NamedBrush[props.Length];
     for (int i = 0; i < props.Length; i++)
     {
         nbrushes[i] = new NamedBrush(props[i].Name, (Brush)props[i].GetValue(null, null));
     }
 }
        // Статический конструктор
        static NamedBrush()
        {
            PropertyInfo[] props = typeof(Brushes).GetProperties(); // Выявляет атрибуты свойства и обеспечивает доступ к его метаданным
            nbrushes = new NamedBrush[props.Length];

            for (int i = 0; i < props.Length; i++)
            {
                nbrushes[i] = new NamedBrush(props[i].Name,
                                             (Brush)props[i].GetValue(null, null)); // Возвращает значение свойства заданного объекта с дополнительными значениями индекса для индексированных свойств
            }
        }