Limited IList<> implementation ?
Posted
by Wam
on Stack Overflow
See other posts from Stack Overflow
or by Wam
Published on 2010-04-12T09:59:27Z
Indexed on
2010/04/12
10:03 UTC
Read the original article
Hit count: 404
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
© Stack Overflow or respective owner