-2

How can I convert color[] into brush[]? I have tried:

for (int i = 0; i < cor3_local.length; i++)
{
Brush cor_local = new SolidBrush(cor3_local[i]);
}

but the cor_local gets no value.

cor3_local is color[5].

motipai
  • 328
  • 3
  • 10
  • 3
    FYI you are reassigning same `cor_local` variable in a loop. And this variable will not be visible outside of the loop. Also it's not clear what is `cor3_local` and what data this array/collection has – Sergey Berezovskiy Oct 15 '15 at 19:56
  • 1
    What does `xmlfile` have to do with the array of colors? – D Stanley Oct 15 '15 at 19:58

1 Answers1

3
var brushes = cor3_local.Select(c => new SolidBrush(c)).ToArray();
Eser
  • 12,346
  • 1
  • 22
  • 32
  • I get the following error: 'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) – motipai Oct 15 '15 at 20:03
  • 1
    You need to include `using System.Linq;` because `Select` is an extension method for arrays defined in that namespace. – wingerse Oct 15 '15 at 20:03