Solved

GetEnumerator Blues

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …

737 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