Jump to content
  • Advertisement
Sign in to follow this  

[.net] Exposing list as IEnumerable Generating Garbage?

This topic is 2730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For some reason when I do this....

//Pseudo Code
public class TheClass
internal List<object> theList;
public IEnumerable<object> TheList { get{return theList;} }

void TheLoop()
foreach(Object obj in TheList)
//Do nothing


Garbage is generated when using the foreach loop. Any idea what I'm doing wrong? I'm not the most informed on the subject but I'm going to guess it has something to do with IEnumerable<T>'s GetEnumerator function. I tried expose the as a list and everything worked fine.

Edit: Also exposing as an ICollection, and IList generate garbage....

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!