Appendix A Solutions to Exercises

All the programmatic exercise solutions are available for download in the downloads for their chapters. For example, the ConsoleShowArgs example program that solves Exercise 1 in Chapter 2, “Writing a First Program,” is contained in the downloads for Chapter 2.

This appendix shows the most interesting parts of many of the programs, but to save space some of the less interesting details are omitted. Download the examples from www.wrox.com/go/csharp5programmersref to see all the code.

Chapter 1

  1. Figure A-1 shows the major steps that Visual Studio performs when you write a C# program and press F5 to run it.
    bapp01f001.eps

    Figure A-1: The C# compiler converts C# code into IL code. Then the CLR’s JIT compiler converts the IL code into machine code. The JIT compiler compiles only methods as they are needed.

  2. In the first application, there will be a small delay because each method is compiled the first time the user selects the corresponding tool. The delay is small, so the user probably won’t notice anything.

    In the second application, all the compilation delays occur when the program starts. It is possible that those delays could add up to enough time for the user to notice. However, the time spent by the methods’ code will probably be far larger, so the user would notice a delay in any case.

    If you precompile the programs and install them in the GAC, they would ...

Get C# 5.0 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.