DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 18 Aug 2007 23:30:42 +0200,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Adam Badura
          2    Göran Andersson


IEnumerator specification inconsistency?   
In MSDN (August 2006) in the specification of IEnumerator.Current there 
is word on exceptions. InvalidOperationException shall be thrown in case 
"The collection was modified after the enumerator was created.". But in the 
remarks section it can be read that "If the collection is modified between 
MoveNext and Current, Current returns the element that it is set to, even if 
the enumerator is already invalidated."
    For me both this sentances seem to be contradictory. Or am I mistaken?
    Also another intersting thing. IEnumerator<T> does not specify 
exceptions at all. In remarks section it says only when Current is 
undefined.

    Framework doesn't seem to do checks at all.

    Adam Badura
Date:Sat, 18 Aug 2007 23:30:42 +0200   Author:  

Re: IEnumerator specification inconsistency?   
Adam Badura wrote:

>     In MSDN (August 2006) in the specification of IEnumerator.Current there 
> is word on exceptions. InvalidOperationException shall be thrown in case 
> "The collection was modified after the enumerator was created.". But in the 
> remarks section it can be read that "If the collection is modified between 
> MoveNext and Current, Current returns the element that it is set to, even if 
> the enumerator is already invalidated."
>     For me both this sentances seem to be contradictory. Or am I mistaken?
>     Also another intersting thing. IEnumerator<T> does not specify 
> exceptions at all. In remarks section it says only when Current is 
> undefined.
> 
>     Framework doesn't seem to do checks at all.
> 
>     Adam Badura 


Yes, that is inconsistent. In the 1.1 version of the documentation, it's 
consistent:

http://msdn2.microsoft.com/en-us/library/system.collections.ienumerator.current(VS.71).aspx

The implementation seems to follow the 1.1 version of the documentation. 
If you for example look at the code for List<T>.Enumerator<T>.Current, 
it only returns the current element without checking the list object 
version:

public T Current {
    get {
       return this.current;
    }
}

-- 
Gran Andersson
_____
http://www.guffa.com
Date:Sun, 19 Aug 2007 02:38:17 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us