Click here to Skip to main content
15,912,400 members
Home / Discussions / C#
   

C#

 
AnswerRe: [Serializable] for class inside class Pin
Roland Bär2-Feb-08 7:18
Roland Bär2-Feb-08 7:18 
GeneralChange the value of text box in another form Pin
Strategic_Thinker2-Feb-08 3:48
Strategic_Thinker2-Feb-08 3:48 
GeneralRe: Change the value of text box in another form Pin
Jacob Dixon2-Feb-08 4:22
Jacob Dixon2-Feb-08 4:22 
GeneralRe: Change the value of text box in another form Pin
Strategic_Thinker2-Feb-08 7:45
Strategic_Thinker2-Feb-08 7:45 
GeneralRe: sig Pin
Luc Pattyn2-Feb-08 7:56
sitebuilderLuc Pattyn2-Feb-08 7:56 
GeneralRe: sig Pin
Paul Conrad2-Feb-08 12:07
professionalPaul Conrad2-Feb-08 12:07 
GeneralExceptions related to IEnumerator Pin
SeeBees2-Feb-08 3:48
SeeBees2-Feb-08 3:48 
GeneralRe: Exceptions related to IEnumerator Pin
Luc Pattyn2-Feb-08 4:22
sitebuilderLuc Pattyn2-Feb-08 4:22 
Hi,

I have not done this yet, but here is an idea:
- in the object you want to be able to enumerate, keep a generation counter that starts at
zero and gets incremented every time you modify the collection (hence Add, Remove, Clear,
... all contain "generation++;")
- in the enumerator hold a copy of the generation counter, equal to the collection's
generation at the moment you create the enumerator
- in each enumerator method compare enumerator generation with collection generation;
when unequal, throw the exception.

Refinement: to reduce the risk of generation overflow, rather than incrementing all the time,
your collection could keep two generation values (current and next), that both start at zero.
Each modification sets "generation=nextGeneration;", and each getEnumerator
does "generation=nextGeneration++;" hence the generation can only increase if an enumerator
has been requested.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: Exceptions related to IEnumerator Pin
SeeBees2-Feb-08 17:05
SeeBees2-Feb-08 17:05 
GeneralRe: Exceptions related to IEnumerator Pin
Luc Pattyn2-Feb-08 17:14
sitebuilderLuc Pattyn2-Feb-08 17:14 
GeneralExchange server 2007 Pin
Abhijit Jana2-Feb-08 3:11
professionalAbhijit Jana2-Feb-08 3:11 
GeneralCustom Toolbar For IE Pin
M. Ahmed2-Feb-08 3:10
M. Ahmed2-Feb-08 3:10 
GeneralRe: Custom Toolbar For IE Pin
TJoe4-Feb-08 2:11
TJoe4-Feb-08 2:11 
GeneralPreventing MDI child icons from being shown Pin
DSdragondude2-Feb-08 2:46
DSdragondude2-Feb-08 2:46 
GeneralPrint using usb printer Pin
mehrdadc482-Feb-08 2:36
mehrdadc482-Feb-08 2:36 
GeneralRe: Print using usb printer Pin
Luc Pattyn2-Feb-08 3:02
sitebuilderLuc Pattyn2-Feb-08 3:02 
Questionhow to attach file to mail using C# code ? Pin
E_Gold2-Feb-08 1:01
E_Gold2-Feb-08 1:01 
AnswerRe: how to attach file to mail using C# code ? Pin
Giorgi Dalakishvili2-Feb-08 1:11
mentorGiorgi Dalakishvili2-Feb-08 1:11 
QuestionHow deploy Browser Help Object (BHO) on targer machine(Deployment managed dll) Pin
sepel1-Feb-08 20:33
sepel1-Feb-08 20:33 
QuestionProxy avoidance?? How do they work?? Pin
Muammar©1-Feb-08 20:17
Muammar©1-Feb-08 20:17 
Questionhow to return arrays from functions? Pin
syamooo1-Feb-08 20:14
syamooo1-Feb-08 20:14 
AnswerRe: how to return arrays from functions? Pin
darkelv1-Feb-08 20:23
darkelv1-Feb-08 20:23 
AnswerRe: how to return arrays from functions? Pin
Guffa2-Feb-08 0:44
Guffa2-Feb-08 0:44 
GeneralWindows Media Player question Pin
C# Beginner Nick1-Feb-08 19:57
C# Beginner Nick1-Feb-08 19:57 
Generalchange or remove pwd from ... Pin
mostafa_h1-Feb-08 19:51
mostafa_h1-Feb-08 19:51 

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.