Working on Maths problems, I'm very fond of LINQ to Data.
I would like to know if LINQ is smart enough to avoid a cast like .ToArray() when the IEnumerable I work with is already an array. See example below:
/// <summary> Transforms an array of timeSeries into one ModelData. </summary>
public static ModelData ToModelData(this IEnumerable<TimeSerieInfo> timeSeries)
{
var seriesArray = timeSeries as TimeSerieInfo[];
return null != seriesArray ?
new ModelData(seriesArray) :
new ModelData(timeSeries.ToArray());
}
Does LINQ avoid the transformation to an array when the IEnumerable<TimeSerieInfo> timeSeries
is already an array?
Thank you for help.