Variable Scoping in Anonymous Delegates in C#
Posted by: Rick Strahls WebLog,
on 27 Apr 2008 |
View original | Bookmarked: 0 time(s)
Every once in a while when I write code that deals with Anonymous Delegates, I still kinda freak out when it comes to the behavior of closures and the variable scoping that goes along with it. For example, the following code uses a List<T>.Find() Predicate to search for items in the list and requires that a dynamic value is compared to: public void AddScript(ScriptItem script){ ScriptItem match = null; // *** Grab just the path if...