473,406 Members | 2,451 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... Suggestion for next framework.

Currently is not possible to remove and item while iterating between them,
so ...

I suggest something like this..

foreach (MyType CurrentItem in MyCollection)
{
MyCollection.Mark(CurrentItem);
}

MyCollection.RemoveMarkedItems();

Aug 17 '06 #1
3 1113
Anibal David Acosta F. wrote:
Currently is not possible to remove and item while iterating between them,
so ...

I suggest something like this..

foreach (MyType CurrentItem in MyCollection)
{
MyCollection.Mark(CurrentItem);
}

MyCollection.RemoveMarkedItems();
I second the motion.
Aug 17 '06 #2
Hi,

Although this does not add much functionality you can't do with a for loop
I would probably use this feature if it existed.

You can suggest features to microsoft using their product feedback center

Search the feature(or bug) on this page and if the feature/bug is not
found or does not apply to your problem you can deliver a new report

http://connect.microsoft.com/feedbac...spx?SiteID=210

Note though that the features of .net 3 has more or less been decided by
now.

On Thu, 17 Aug 2006 04:57:35 +0200, Anibal David Acosta F. <aa@pla.net.py
wrote:
Currently is not possible to remove and item while iterating between
them,
so ...

I suggest something like this..

foreach (MyType CurrentItem in MyCollection)
{
MyCollection.Mark(CurrentItem);
}

MyCollection.RemoveMarkedItems();


--
Happy Coding!
Morten Wennevik [C# MVP]
Aug 17 '06 #3
Firstly, foreach only currently uses the IEnumerable / IEnumerable<T>
interface, so you'd need to declare such usage in a super-interface. After
all, not all such lists are writeable.

This type of usage would be a pain thread wise - you'd need to be damned
sure that nobody else was using .Mark() [which, OK, you need to watch for
anyway as the iterator will barf], plus note you would need a
..ResetMarkings() at the start in case another caller didn't complete (after
marking a few). By the time you've done that why not just have done with it
and use your own List<Tor whatever to store the marked items, and remove
them in a separate block afterwads? I'm not sure it really adds any more
code...

Perhaps this could be solved by an overload to RemoveAll() (for List<T>; new
for Collection<T>) that accepted an IEnumerable<T>? But then you couldn't
add this to IList<Tor ICollection<Twithout it being a breaking change,
so you'd need another new interface... etc.

All in all, I'm not sure it would be worth the extra complexity. Just my
tuppence.

Marc
Aug 17 '06 #4

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

Similar topics

8
by: Arnaud Debaene | last post by:
Hello all, One area where the .Net framework 1.1 is really poor is Collections : We've got very few choice concerning the containers and their characteristics (for example, ArrayList, Queue and...
3
by: Sandeep Limaye | last post by:
Hi, I want to use collections (similar to maps in STL) in my C# code. I looked up MSDN but they say that you need to inherit from the System.Collections.Specialized.NameObjectCollectionBase...
1
by: Mark Miller | last post by:
I just recently started getting the above error on a page I am posting MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter installed on the server in question and up until a day...
0
by: Ross M | last post by:
Dear Microsoft, I m getting this error message, on every SECOND attempt to access a web service on a foreign PC. I am using .net framework 2 beta 2 with Visual Web developer 2. Below is the...
7
by: Bmack500 | last post by:
I'm definitely doing something wrong here. I have a class called Servers, implemented as below. I then create my collection as below. Then, I'll add a server object to the collection as follows: ...
5
by: Simon | last post by:
Hi all, I am writing a windows application using vb.net on the 1.1 framework. We have in the application, some strongly typed collections that have been written as classes that do not inherit...
11
by: CMM | last post by:
First let me say that maybe I'm having a "duh" moment and perhaps I'm missing something... but it seems to me that no one thing in the System.Collections namespace (even in .NET 2.0) even comes...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
0
by: marcello | last post by:
Hi, I'm quite new to c# and OO programming, in brief... I developed a 'classic' ASP / MSXML application, so I used VBsricpt for the logic, xml files for storing informations and standard XSLT...
5
by: WebSnozz | last post by:
Some collections are such that efficient search algorithms work on them such as binary search if the collection is a type which is sorted. I'm wondering how LINQ searches these collections and if...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.