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 ( imag开发者_StackOverflowe.Effects [ i ] );
}
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.
Linq would be something like this:
this.Effects = image.Effects.Select(x => new Effect(x)).ToArray();
Or use the Parallel.For
to use multiple threads.
精彩评论