DEV Community

Discussion on: Using Extension Methods in C# to Build Fluent Code

Collapse
 
vasar007 profile image
Vasily Vasilyev

Next our example has us calling WrittenBy. Well, the BookBuilder class doesn’t define that method. In a normal application we’d probably just add the method to BookBuilder, but that wouldn’t let us play with extension methods here, so let’s pretend that the BookBuilder class is defined by some code we don’t control and can’t modify.

(I emphasised the main purpose)

Collapse
 
integerman profile image
Matt Eland

It's a very valid question. The answer is "I need to teach extension methods". If you have full control of all code, you're better off putting it in BookBuilder.