Sign in to follow this  

[.net] Exposing list as IEnumerable Generating Garbage?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this