Solved

GetEnumerator Blues

Posted on 2006-07-15
2
633 Views
Last Modified: 2012-08-13
I am using indexers for the first time and I cant see there where the issues is
Here is my indexer and add functions
class paragraph
{
       ArrayList _para = new ArrayList();
        public void add(string path, string filename, string extention, double start, double end, double length)
        {
            _para.Add(new paragraph(path,filename,extention,start,end,length));
        }
        public object this[int idx]
        {
            get
            {
                if (_para.Count < idx)
                {
                    return _para[idx];
                }
                else
                {
                    throw new IndexOutOfRangeException("paragraph.get.item" + " Index out of range");
                }
            }
            set
            {
                if (_para.Count < idx)
                {
                    _para[idx] = value;
                }
           
            }

}


class production
{
         paragraph _para = new paragraph();
        public paragraph para
        {
            get { return _para; }
            set { _para = value; }

        }

 ArrayList prAR = new ArrayList();
             foreach (paragraph myPara in this.para)
             {
             
                 prAR.Add(new filemakerFields("path", myPara.path));
                 prAR.Add(new filemakerFields("filename", myPara.filename));
                 prAR.Add(new filemakerFields("extention", myPara.extention));
                 prAR.Add(new filemakerFields("length", myPara.length.ToString()));
                 prAR.Add(new filemakerFields("starttime", myPara.startTime.ToString()));
                 prAR.Add(new filemakerFields("endtime", myPara.endTime.ToString()));
                 fm.insertValues.Clear();
                 fm.insertValues = prAR;
                 int newParaID = fm.insert();
                 int lkrecID = addAudioFileLookup("paragraph",newParaID);
                 if(lkrecID == -1)
                 {
                    throw new Exception("Error Adding Paragraph");
                 }
             }
}


When I build I get the following errror

Error      2      foreach statement cannot operate on variables of type 'application1.paragraph' because 'AudioMixv7.paragraph' does not contain a public definition for 'GetEnumerator'      C:\production.cs      183      14      Application1

Where am I going wrong?
0
Comment
Question by:onholdmarketing
2 Comments
 
LVL 7

Accepted Solution

by:
yotamsher earned 500 total points
ID: 17114662
Hey  onholdmarketing

a small coment on your post: if you could include the Compiler error ID, in this case CS1579 it could be of help.
anyway I think Microsoft page on this error will give you all the details, on what's needed to "foreach" a class

http://msdn2.microsoft.com/en-us/library/t51esaeb.aspx

Yotam
0
 

Author Comment

by:onholdmarketing
ID: 17114698
the complier error ID was CS1579 Thanks Ill take a look
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question