Saturday, 17 February 2018

c# - Is it better to declare a variable inside the loop or outside the loop?

I like to limit variable scope as much as possible. The first option scopes the variable to the entire containing function, while the latter limits it to just within the loop. Therefore, I prefer the latter unless I explicitly need access to the variable after the loop completes.

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...