Reformat and improve sample code

I've reformatted the code samples according to the defaults in Visual Studio and improved some of them to better illustrate the differences and similarities between the two languages.