Double dispatch in C#?
问题 I have heard/read the term but don\'t quite understand what it means. When should I use this technique and how would I use it? Can anyone provide a good code sample? 回答1: The visitor pattern is a way of doing double-dispatch in an object-oriented way. It's useful for when you want to choose which method to use for a given argument based on its type at runtime rather than compile time. Double dispatch is a special case of multiple dispatch . When you call a virtual method on an object, that's