Solved

GetEnumerator Blues

Posted on 2006-07-15
2
629 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
Comment Utility
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
Comment Utility
the complier error ID was CS1579 Thanks Ill take a look
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …
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 …

763 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

16 Experts available now in Live!

Get 1:1 Help Now