r0k3t (3) [Avatar] Offline
Hi there,

I am very pleased with your book, there is much I have learned from it but I am little confused about the example in 10.2, you have an extra method there. The ReadFully() method which you also migrate from a simple static class to an extension method, now I had to read and re-read that a few times to figure out indeed, nothing happens with that method, it never gets called in the example, I even did a test to make sure I wasn't crazy, the code works of course with or without the code for ReadFully(). My questions is this... Why is it there? Am I missing something, did you include that method for some reason, like I should be looking at it going, "Oh, what a great idea..." - It's making me nuts!

Thanks for your response, great book!
mgravell (64) [Avatar] Offline
Re: Question about extension method example 10.2
Do you mean Listing(s) 10.3 / 10.4?

I believe the intent is to show how you might write such utility methods. You are right in that this isn't used in the example but to use this method would be something like:

byte[] blob = myStream.ReadFully();

It is still a useful method to have up your sleeve (even if the example doesn't use it) - but note that it is only suitable if you expect the size to be reasonable ;-p
jon.skeet (448) [Avatar] Offline
Re: Question about extension method example 10.2
Yes, Marc's got the right idea - it's a general demonstration of a useful utility method which again looks better as an extension method.