Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:22:14+00:00 2026-05-24T14:22:14+00:00

here is i am trying to work. List<MasterEmployee > masterEmployee = new List<MasterEmployee >();

  • 0

here is i am trying to work.

List<MasterEmployee > masterEmployee = new List<MasterEmployee >();
masterEmployee = MasterEmployee.GetAll("123"); //connecting db and returning a list...


  foreach (MasterEmployee item in masterEmployee)
   {
      foreach (Registration reg in item.Registration) //<<<error here...
      {
           //
      }
  }

error here:

Error   2   foreach statement cannot operate on variables of type Registration because Registration does not contain a public definition for 'GetEnumerator'

i have a class called MasterEmployee and in it i have a with few props and few methods on it

 [Serializable]
    public class MasterEmployee 
    {

        //few props omitted  ....

        protected Registration _registration;
        [CopyConstructorIgnore]
        public Registration Registration
        {
            get
            {
                return _registration;

            }
            set
            {
                this._registration = value;
            }
        }
        protected User _user;
        [CopyConstructorIgnore]
        public User MyUser
        {
            get
            {
               return _user;
            }
            set
            {
                this._user= value;
            }
        }

        protected Student _student;
        [CopyConstructorIgnore]
        public Student Student
        {
            get
            {
                return _student;
            }
            set
            {
                this._student = value;
            }
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:22:16+00:00Added an answer on May 24, 2026 at 2:22 pm

    The explanation provided in the error message is clear enough. You are trying to iterate item.Registration, which is an instance of Registration. However, Registration is not derived from an iterable type, and does not implement the GetEnumerator function required for custom iterable types. So it cannot be iterated using a foreach loop.

    But I believe either your naming conventions are incorrect, or you have misunderstood your data model. Why would a Registration instance ever contain a collection of Registration instances? If an item can have multiple Registration instances associated with it, then the property should be called something like item.Registrations, and it should not be of type Registration, it should be a list/collection type that contains Registration instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programming Student here...trying to work on a project but I'm stuck. The project is
Hey all, here is the issue I am currently trying to work through. We
I am trying to do work with examples on Trees as given here: http://cslibrary.stanford.edu/110/BinaryTrees.html
Here's a problem I've been trying to solve at work. I'm not a database
Here's what I'm trying to do -- this is pseudo code and doesn't work.
I'm trying to introduce dependency injection (DI) as a pattern here at work and
Here is what i am trying to do private ToggleButton _itemChecked=Name_Of_Element_In_Xaml; That doesnt work.
I'm trying to understand how parallelism might work using PLINQ, given delayed execution. Here
I am trying to get the code found here: http://snipplr.com/view/26643/mbprogresshud-with-an-asynchronous-nsurlconnection-call/ to work in my
I'm trying to work with a jQuery plug-in which can work with a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.