Click here to Skip to main content
15,896,453 members
Home / Discussions / C#
   

C#

 
AnswerRe: Foreign key UniqueIdentifier Pin
PIEBALDconsult7-Jul-10 3:22
mvePIEBALDconsult7-Jul-10 3:22 
AnswerRe: Foreign key UniqueIdentifier Pin
tek 20097-Jul-10 4:19
tek 20097-Jul-10 4:19 
AnswerRe: Foreign key UniqueIdentifier Pin
Bernhard Hiller7-Jul-10 3:57
Bernhard Hiller7-Jul-10 3:57 
QuestionHelp! URGENT Pin
Ice_Freez056-Jul-10 22:44
Ice_Freez056-Jul-10 22:44 
AnswerSuggestion PinPopular
DaveyM696-Jul-10 22:53
professionalDaveyM696-Jul-10 22:53 
GeneralRe: Suggestion Pin
Ice_Freez057-Jul-10 15:23
Ice_Freez057-Jul-10 15:23 
QuestionCollection remove Pin
MayukhSen6-Jul-10 22:34
MayukhSen6-Jul-10 22:34 
AnswerRe: Collection remove Pin
Dave Kreskowiak7-Jul-10 1:37
mveDave Kreskowiak7-Jul-10 1:37 
montosen wrote:
public void Clear(T item) { foreach (T it in base.Items) { if(it.Equals(item)) base.Remove(item); } }


You cannot remove an item from a collection while enumerating over the collection with a foreach. Youd would have to use an index into the collection instead.

Also, the name you picked for this method, "Clear", would tell me that the method removes all items from the collection, not just a single element. "Remove" would be a better choice.

Why are you even implementing this Clear (Remove) method when the base Collection class already implements it?

A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008
But no longer in 2009...




GeneralRe: Collection remove Pin
MayukhSen7-Jul-10 2:02
MayukhSen7-Jul-10 2:02 
GeneralRe: Collection remove Pin
Pete O'Hanlon7-Jul-10 2:38
mvePete O'Hanlon7-Jul-10 2:38 
QuestionRemote desktop server/client Pin
Sajjad Izadi6-Jul-10 21:05
Sajjad Izadi6-Jul-10 21:05 
AnswerRe: Remote desktop server/client Pin
Richard MacCutchan6-Jul-10 21:39
mveRichard MacCutchan6-Jul-10 21:39 
AnswerRe: Remote desktop server/client Pin
Gonzalo Cao6-Jul-10 21:41
Gonzalo Cao6-Jul-10 21:41 
AnswerRe: Remote desktop server/client Pin
Abhinav S6-Jul-10 21:41
Abhinav S6-Jul-10 21:41 
GeneralRe: Remote desktop server/client Pin
JHizzle6-Jul-10 22:00
JHizzle6-Jul-10 22:00 
QuestionDisplay messages, when using windows services Pin
ayandelhi6-Jul-10 19:28
ayandelhi6-Jul-10 19:28 
AnswerRe: Display messages, when using windows services Pin
Peace ON6-Jul-10 20:31
Peace ON6-Jul-10 20:31 
GeneralRe: Display messages, when using windows services Pin
Gonzalo Cao6-Jul-10 20:37
Gonzalo Cao6-Jul-10 20:37 
AnswerRe: Display messages, when using windows services Pin
Luc Pattyn6-Jul-10 23:36
sitebuilderLuc Pattyn6-Jul-10 23:36 
GeneralRe: Display messages, when using windows services Pin
Rod Kemp12-Jul-10 16:15
Rod Kemp12-Jul-10 16:15 
AnswerRe: Display messages, when using windows services Pin
Jammer6-Jul-10 22:21
Jammer6-Jul-10 22:21 
AnswerRe: Display messages, when using windows services Pin
geo_m8-Jul-10 1:33
geo_m8-Jul-10 1:33 
QuestionUsing Registry Keys Pin
Richard Blythe6-Jul-10 12:27
Richard Blythe6-Jul-10 12:27 
AnswerRe: Using Registry Keys Pin
Manas Bhardwaj6-Jul-10 12:34
professionalManas Bhardwaj6-Jul-10 12:34 
GeneralRe: Using Registry Keys Pin
Richard Blythe6-Jul-10 13:10
Richard Blythe6-Jul-10 13:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.