Reputation: 331052
I have to do these kinds of initializations all over for different members:
this.Effects = new Effect [ image.Effects ];
for ( int i = 0; i < image.NumEffects; ++i )
{
this.Effects [ i ] = new Effect ( image.Effects [ i ] );
}
Upvotes: 2
Views: 819
Reputation: 3449
Linq would be something like this:
this.Effects = image.Effects.Select(x => new Effect(x)).ToArray();
Upvotes: 5
Reputation: 887453
Like this:
this.Effects = Array.ConvertAll(image.Effects, e => new Effect(e));
This will be faster than the equivalent LINQ calls with Select
and ToArray
which will probably be answered shortly after this.
Upvotes: 24