KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What is happening differently in the background for these two code blocks? Would one be considered "better" than the other? My thought is that Example2 might be worse because it might have to wait for the garbage collector to dispose of the item, but I don't know enough about the garbage collector to know if that is true. Example1: ListItem item; for (int i = 1; i <= 32; i++) { item = new ListItem(); //do some stuff } Example2: for (int i = 1; i <= 32; i++) { ListItem item = new ListItem(); //do some stuff }
Tags (comma-separated)
Save Edits
Cancel