C# delegate definition - anonymous methods vs. formally defined methods
问题 When should anonymous methods be used when defining a delegate and when should formally defined methods be used when defining a delegate ? 回答1: If you need to use the same logic in more than one place, it makes sense to use a separate method. If you only need to use the logic once and it's fairly short, it makes sense to use an anonymous function. If the delegate needs access to local variables in the method which is creating it, anonymous functions act as closures which can also be very