I just looked at this posting: What is the best or most interesting use of Extension Methods you’ve seen?
I’ve never heard of extension methods. Do they apply to every language?
What is the point of them? In that particular posting I did not understand the example.
They are available to C# and VB. They allow you to simulate the addition of methods to classes that are not under your control.
You could, for instance, you could add a
WordCountmethod to string.So instead of
MyStringUtils.WordCount( "some string" )You could just write
"some string".WordCount().This is strictly “syntactic sugar” and aids in readability. You’re essentially creating a static method that will be shown in the IntelliSense for the target type.