?
Solved

GetEnumerator Blues

Posted on 2006-07-15
2
Medium Priority
?
636 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
yotamsher earned 1000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

770 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