Click here to Skip to main content
15,925,206 members
Home / Discussions / C#
   

C#

 
Question[Serializable] for class inside class Pin
Roland Bär2-Feb-08 6:58
Roland Bär2-Feb-08 6:58 
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 
According to MSDN, methods of IEnumerator are expected to throw an exception if the enumerated collection has been modified

For Example,
<br />
            List<int> list = new List<int>();<br />
            list.Add(1);<br />
<br />
            IEnumerator enumerator = list.GetEnumerator();<br />
<br />
            enumerator.Reset(); // It' ok to reset the enumerator<br />
<br />
            list.Add(2);  // The collection is modified.<br />
<br />
            enumerator.Reset(); // Now InvalidOperationException is raised<br />


When implementing the methods of IEnumerator in our own class, we should have them throw the exception if the collection is modified.

Now I have a class :
<br />
    class MyEnumerator:IEnumerator{<br />
        int[] integers;<br />
        <br />
        /// <br />
        /// Methods <br />
        /// <br />
<br />
        public void Reset(){ }<br />
    }


How to implement Reset in an elegant way, so that I can throw an InvalidOperationException when Reset is called after integers are modified?

Thank you! Blush | :O
GeneralRe: Exceptions related to IEnumerator Pin
Luc Pattyn2-Feb-08 4:22
sitebuilderLuc Pattyn2-Feb-08 4:22 
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 

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.