X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem%2FArray.cs;h=91424bc6f8f6dfbf4d2c5457e453f4db01add388;hb=410bb8a57e23a901ea47d8a74f88a20972de423d;hp=00e0430d3de27dc3b5019a4a2cb84604d1934cc4;hpb=7b3c90779663df8d1e9b1bc5dc4986a4b5d5043c;p=mono.git diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs index 00e0430d3de..91424bc6f8f 100644 --- a/mcs/class/corlib/System/Array.cs +++ b/mcs/class/corlib/System/Array.cs @@ -68,7 +68,10 @@ namespace System internal IEnumerator InternalArray__IEnumerable_GetEnumerator () { - return new InternalEnumerator (this); + if (Length == 0) + return EmptyInternalEnumerator.Value; + else + return new InternalEnumerator (this); } internal void InternalArray__ICollection_Clear () @@ -207,7 +210,7 @@ namespace System // we just decr the size, so, 0 - 1 == FINISHED const int FINISHED = -1; - Array array; + readonly Array array; int idx; internal InternalEnumerator (Array array) @@ -218,7 +221,6 @@ namespace System public void Dispose () { - idx = NOT_STARTED; } public bool MoveNext () @@ -272,6 +274,38 @@ namespace System } } + internal class EmptyInternalEnumerator : IEnumerator + { + public static readonly EmptyInternalEnumerator Value = new EmptyInternalEnumerator (); + + public void Dispose () + { + return; + } + + public bool MoveNext () + { + return false; + } + + public T Current { + get { + throw new InvalidOperationException ("Enumeration has not started. Call MoveNext"); + } + } + + object IEnumerator.Current { + get { + return Current; + } + } + + void IEnumerator.Reset () + { + return; + } + } + // InternalCall Methods [MethodImplAttribute (MethodImplOptions.InternalCall)] extern int GetRank ();