Click here to Skip to main content
15,881,803 members
Home / Discussions / C#
   

C#

 
GeneralRe: Changing Order of Items in a Bound ListBox Pin
myNameIsRon2-May-06 16:05
myNameIsRon2-May-06 16:05 
QuestionData Grid - Setting Current Column and arrow key capture Pin
Michael A. Barnhart1-May-06 12:15
Michael A. Barnhart1-May-06 12:15 
QuestionDLL question Pin
Tom Wright1-May-06 12:12
Tom Wright1-May-06 12:12 
AnswerRe: DLL question Pin
Robin Panther1-May-06 13:07
Robin Panther1-May-06 13:07 
QuestionPassportIdentity.Compress - ?? Pin
BlackDice1-May-06 11:23
BlackDice1-May-06 11:23 
GeneralRe: PassportIdentity.Compress - ?? Pin
Office Lineman1-May-06 13:53
Office Lineman1-May-06 13:53 
GeneralRe: PassportIdentity.Compress - ?? Pin
BlackDice2-May-06 5:28
BlackDice2-May-06 5:28 
QuestionEnumerator question Pin
jbricker771-May-06 9:28
jbricker771-May-06 9:28 
Long time Java programmer running into a C# issue I can not figure out.

I have a class that contains a List. Other classes need iterate through the list. What I have below is not working. I get an excpetion at runtime about Current being outofRange.

Should I just return an Enumerator from the List or is there a way to do it like this that I'm missing.

thanks for the help.

Class Foo<br />
{<br />
    List<Bar> list;<br />
<br />
    list = fill_it_up(); // fills the list <br />
<br />
     public class FooIterator : IEnumerator<br />
     {<br />
        protected int lastVisited;<br />
<br />
                public FooIterator ()<br />
                {<br />
                    lastVisited = -1;<br />
                    <br />
                }<br />
<br />
                #region IEnumerator Members<br />
<br />
                public object Current<br />
                {<br />
                    get<br />
                    {<br />
                        <br />
                            return list[lastVisited].thisBar;<br />
                        <br />
                    }<br />
                }<br />
<br />
                public bool MoveNext()<br />
                {<br />
                    return ++lastVisited < list.Count - 1;<br />
                }<br />
<br />
                public void Reset()<br />
                {<br />
                    throw new Exception("The method or operation is not implemented.");<br />
                }<br />
<br />
                #endregion<br />
            }<br />
     }<br />
<br />
}

AnswerRe: Enumerator question Pin
Josh Smith1-May-06 9:32
Josh Smith1-May-06 9:32 
GeneralRe: Enumerator question Pin
jbricker772-May-06 2:48
jbricker772-May-06 2:48 
AnswerRe: Enumerator question Pin
Robin Panther1-May-06 12:57
Robin Panther1-May-06 12:57 
GeneralRe: Enumerator question Pin
jbricker772-May-06 3:22
jbricker772-May-06 3:22 
AnswerRe: Enumerator question Pin
jbricker772-May-06 3:37
jbricker772-May-06 3:37 
AnswerRe: Enumerator question Pin
jbricker772-May-06 8:46
jbricker772-May-06 8:46 
QuestionPainting an ActiveX Control to an Image Pin
kingphotis1-May-06 8:41
kingphotis1-May-06 8:41 
AnswerRe: Painting an ActiveX Control to an Image Pin
Judah Gabriel Himango1-May-06 9:34
sponsorJudah Gabriel Himango1-May-06 9:34 
GeneralRe: Painting an ActiveX Control to an Image Pin
kingphotis1-May-06 9:42
kingphotis1-May-06 9:42 
QuestionHow to refresh Win Form [C# 2.0 ] Pin
student_rhr1-May-06 8:04
student_rhr1-May-06 8:04 
AnswerRe: How to refresh Win Form [C# 2.0 ] Pin
Josh Smith1-May-06 8:17
Josh Smith1-May-06 8:17 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
student_rhr1-May-06 8:31
student_rhr1-May-06 8:31 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
Josh Smith1-May-06 8:53
Josh Smith1-May-06 8:53 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
student_rhr1-May-06 9:18
student_rhr1-May-06 9:18 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
Josh Smith1-May-06 9:23
Josh Smith1-May-06 9:23 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
student_rhr1-May-06 9:46
student_rhr1-May-06 9:46 
GeneralRe: How to refresh Win Form [C# 2.0 ] Pin
student_rhr1-May-06 9:56
student_rhr1-May-06 9:56 

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.