PC Review


Reply
Thread Tools Rate Thread

Collections set accessors

 
 
Mikeyranks
Guest
Posts: n/a
 
      2nd Aug 2007
Using the .NET framework and some other third party API's I've
noticed
that objects with a collection property generally don't have a set
accessor? That is to say I have not yet managed to find one yet.

After searching around I've not managed to find a reason why other
than that it forces you to use the the provided .Add(), .Remove(),
RemoveAt() methods of the collection.


Why cant I do something like:


this.imageList1.Images = myImageCollection;


Any elements in myImageCollection would have had to have used these
methods anyway so I can't see why I have to enumerate and add
individually.


I cannot seem to find any information as to why this is? Is there an
unspoken rule or design pattern that discourages setting all the
collection elements in one go? Is this the same across other
languages/platforms?


Thanks

 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      2nd Aug 2007

"Mikeyranks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Using the .NET framework and some other third party API's I've
> noticed
> that objects with a collection property generally don't have a set
> accessor? That is to say I have not yet managed to find one yet.
>
> After searching around I've not managed to find a reason why other
> than that it forces you to use the the provided .Add(), .Remove(),
> RemoveAt() methods of the collection.
>
>
> Why cant I do something like:
>
>
> this.imageList1.Images = myImageCollection;


That imageList.Images is derived from System.Windows.Forms Namespace.

A collection is derrived form the System.Collection Namespace, and I am
pretthy sure you can't get away with that up above.


If Names1 and Names2 are derived from System.Collection you should be ables
to do Name1 = Name2

Or if a method was returning a System.Collection then you can do this.

Names1 = Names.GetNames() // with GetNames returning System.Collection.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collections set accessors michael.grounds@googlemail.com Microsoft C# .NET 3 2nd Aug 2007 08:47 PM
property get and set accessors Mike P Microsoft C# .NET 3 14th Dec 2004 10:04 AM
Collections of Collections David Morton Microsoft Excel Programming 6 13th Nov 2004 02:10 AM
Inheriting VB6 dll classes/collections into dotnet classes/collections =?Utf-8?B?Q2hhcmxlcw==?= Microsoft Dot NET Framework 0 30th Apr 2004 02:56 PM
Custom Parameter Attribute for Set Accessors =?Utf-8?B?QmVuIEJsYWly?= Microsoft C# .NET 2 30th Jan 2004 10:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.