Sunday, March 18, 2012

For Each Loop is a reference type

A small clarity in the way we write code gives a lot of time to save while coding, for example:

Earlier I used to use for each loop to iterate through elements of a list and then modify them, copy them to a third variable and then copy them back to a  the original.  However, recently I came to know that For Each Loop is a reference type, hence now I can simply just modify loop elements without creating a new list and copy back the items.

By getting clarity on what we are doing is good, and having good grip of what is going on under is excellent to shorten the code.  I see coders writing code with all the wildcards, I still can’t understand that, a lot more distance to go.

No comments:

Post a Comment