From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Work with extension methods

Work with extension methods

- [Instructor] Extension methods allow us to add new methods to existing types as if they were part of the original type. This is the code that we saw on the slides. It's an extension method. You can see that here on line 4. It's extending the string class and it'll return a string. And the code here is converting any string to a title case. Now I'm using that over here. I have a lowercase string. I have another string to hold the results. And then when I go to the string instance and type in the dot operator, you can see my method listed here. So even though this wasn't written by the developers who wrote the string class, I'm able to use it as though it was, and the symbol here, this down pointing arrow is the indication that this is an extension method. This purple box symbol is a regular method. The one with the arrow is an extension method and you can filter by clicking on these buttons down here. This shows only the standard methods and this shows the extension methods. Let's go…

Contents