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, 4 Aug 2007 23:13:36 +0200,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Adam Badura


Questions on specifications of ICollection<T> and IDictionary<K,V>   
I tried to implement the System.Collections.Generic.IDictionary<K,V> 
interface. The task is not that hard but I have some problems with the 
interpretation of the specification of interface members.

    1) Exception specification on 
System.Collections.Generic.ICollection<T>.CopyTo

1.1) arrayIndex out of range

    The specification says that ArgumentOutOfRangeException shall be thrown 
in case arrayIndex is less then 0. But if arrayIndex is greater then the 
length of array then ArgumentException shall be thrown. Why? Why not 
ArgumentOutOfRangeException which seems quite logical.
    Is it because if arrayIndex >= array.Length then there is possibility 
that the arrayIndex is OK but user passed bad array and bad array of course 
should not cause ArgumentOutOfRangeException. So general ArgumentException 
is used? Or why?

1.2) array is multidimensional

    In such a case ArgumentException should be thrown. But what if parameter 
type T is an array type? (Here I am not sure if it is possible and if array 
of arrays is treated as a multidimensional array.)

1.3) type casting

    ArgumentException shall be thrown in case parameter type T cannot be 
cast automaticlly to the type of the array. But how is this ever possible 
since the array is of type T[] and collection elements are of type T (or 
derived type)?

    2) System.Collections.Generic.ICollection<T>.Add respecification in 
System.Collections.Generic.Dictionary<K,V>

    The specification of System.Collections.Generic.ICollection<T>.Add lists 
only one possible exception, NotSupportedException in case of adding to 
read-only collection. However the (explicit) implementation in Dictionary<K, 
V> adds ArgumentException in case the key already exists.
    Perhabs I don't understeand the idea of the specification but I thought 
that if we do specify what can be thrown than we don't change it so 
drasticly in derived classes.

    Adam Badura
Date:Sat, 4 Aug 2007 23:13:36 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


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