Chris Zeigler

Chris Zeigler

  • NA
  • 3
  • 1.8k

Weird array issue

Aug 17 2010 1:49 PM
Hey all, I've got something weird going on with an array.  The code is posted below.  This code works just fine in of itself, so I pasted the exact code into a part of another program I was working on.  The first loop will run through just fine and print every element in the array.  The issue is in the second loop, the entire array seems to have been somehow set to the last element.  Again, this exact same code worked in another place, but pasting it into this program and not calling anything else seems to break it.  Any help?

IADoc[] IADocs = new IADoc[recordAmount];
                int i = 0;

                while (myReader.Read())
                {
                    fileNumber = myReader["itemnum"].ToString();
                    content = myReader["itemtypenum"].ToString();
                    metadata = myReader["itemname"].ToString();
                    IADocs[i] = new IADoc(fileNumber, content, metadata);
                    Console.WriteLine(IADocs[i].toString());
                    i++;
                }

                for (int j = 0; j < IADocs.Length; j++)
                {
                    Console.WriteLine(IADocs[j].toString());
                }

Answers (1)