473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Collections set accessors

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

Aug 2 '07 #1
1 1108

"Mikeyranks" <mi*************@googlemail.comwrote in message
news:11*********************@i38g2000prf.googlegro ups.com...
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.
Aug 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Christopher J. Bottaro | last post by:
If I have the following class: class MyClass: def __init__(self): m_dict = {} m_dict = 1 m_dict = 2 m_dict = 3 Is there anyway to generate automatic accessors to the elements of the dict?
2
by: cody | last post by:
Does the clr allow more than one set and one get method for a property? Is it possible to use overloading for example set_Color(int c), set_Color(Color c)? from msdn: ...
10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
1
by: Brad Williams | last post by:
When I try to define accessors for this event, the event invocation line stops compiling. What's wrong? public class TestClass { public delegate int MyDelegate(string s); public event...
3
by: Peter Cresswell | last post by:
Hello everyone, I would like to serialize an object to XML. Currently my code will serialize all of the public properties that are value types, but not my public properties that have get...
0
by: mrvernon | last post by:
Say an ASP.NET service has a class with accessors with corresponding private data, for instance: class Foo { private int bar; public int Bar { get { return bar; } set { value = bar; }
1
by: Rafael Pivato | last post by:
There is something like C# Event Accessors at VB.NET ? ----- Rafael Pivato
112
by: mystilleef | last post by:
Hello, What is the Pythonic way of implementing getters and setters. I've heard people say the use of accessors is not Pythonic. But why? And what is the alternative? I refrain from using them...
4
by: Magnus.Moraberg | last post by:
Hi, I am a newbie to C# and I have a simple question for you. I have the following two classes which are used to present information in Excel. public class Environment : ICloneable,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.