Solved

GetEnumerator Blues

Posted on 2006-07-15
2
630 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

947 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now