Sometimes, you need to perform some in-memory compression of a large amount of text. You might want to write this to a file or a database. Perhaps you need to e-mail the text as an attachment that another system will pick up and then decompress. Whatever the reason, in-memory compression and decompression is a very useful feature to have around. The best way to do this is to use extension methods. If you haven't figured this out by now, I quite like using extension methods.
In-memory stream compression and decompression
Getting ready
The code is very straightforward. There is not much you will need to get ready beforehand. Just make sure that you include the following using statements in your project and that you have a file containing text called file 3.txt...