Hello people,
I'm doing some work with stats, and want to refactor the following method :
public static blah(float[] array)
{
//Do something over array, sum it for example.
}
However, instead of using float[] I'd like to be using some kind of indexed enumerable (to use dynamic loading from disk for very large arrays for example). I had created a simple interface, and wanted to use it.
public interface IArray<T> : IEnumerable<T>
{
T this[int j] { get; set; }
int Length { get; }
}
My problem is :
- float[] only inherits IList, not IArray, and AFAIK there's no way to change that.
- I'd like to ditch IArray and only use IList, but my classes would need to implement many methods like
Add
,RemoveAt
although they are fixed size - And then my question : how can float[] implement IList whereas it doesn't have these methods ?
Any help is welcome. Cheers