© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
40 replies
olleeee

✅ Lists is the same index all the time.

Hi, i have built different lists for different houses in Hogwarts and now Im trying to add members to the different houses through a sorting hat method. But every time the same house just get members added, why?
  public void SortingHat(Wizard wizard, List<House> hogwarts)
  {
      foreach (House house in hogwarts)
      {
          house.Members.Add(wizard);
          break;
      }

  }
  public void SortingHat(Wizard wizard, List<House> hogwarts)
  {
      foreach (House house in hogwarts)
      {
          house.Members.Add(wizard);
          break;
      }

  }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

NATS Client timeouts all the time
C#CC# / help
4y ago
Help with Lists and index.
C#CC# / help
3y ago
Time Triggered Azure Function | NextStatus is same with current time
C#CC# / help
2y ago
❔ Lists
C#CC# / help
3y ago