13.07.2015 Views

C# in Depth

C# in Depth

C# in Depth

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

30 CHAPTER 1 The chang<strong>in</strong>g face of <strong>C#</strong> development1.4.2 Introduc<strong>in</strong>g SnippyJust know<strong>in</strong>g what the code would look like isn’t terribly helpful, so I’ve written a smalltool that you can download from the book’s website. It’s written <strong>in</strong> WPF, so you’ll needto have .NET 3.0 or higher <strong>in</strong>stalled <strong>in</strong> order to run it. Figure 1.6 shows a screenshot ofit <strong>in</strong> action.It’s not a visual masterpiece, but it does the job. You can edit the code, compile it,and run it. There are different options available to use different us<strong>in</strong>g directives andreferences depend<strong>in</strong>g on which part of the book you are look<strong>in</strong>g at, although thechoice of “.NET 3.5” will compile anyth<strong>in</strong>g that doesn’t require extra custom references.Snippy doesn’t try to work out which us<strong>in</strong>g directives are actually required by thecode, so the full code is rather longer than the examples <strong>in</strong> the previous section, buthav<strong>in</strong>g extra us<strong>in</strong>g directives is harmless.Aside from the WPF requirement to run Snippy, everyth<strong>in</strong>g <strong>in</strong> the <strong>C#</strong> 2 section ofthe book compiles and runs with only .NET 2.0 <strong>in</strong>stalled, and all the snippets compileand run with .NET 3.5 <strong>in</strong>stalled. There’s a s<strong>in</strong>gle button to compile and run, as you’reunlikely to want to do anyth<strong>in</strong>g after a successful compilation other than runn<strong>in</strong>gthe code.As I mentioned earlier, not all examples work this way—the examples <strong>in</strong> this chapter,for <strong>in</strong>stance, all require the Product type, which isn’t <strong>in</strong>cluded <strong>in</strong> every snippet. Fromthis po<strong>in</strong>t on, however, I will give fair warn<strong>in</strong>g whenever a list<strong>in</strong>g isn’t a snippet—sounless you hear otherwise, you should be able to type it <strong>in</strong> and play around with it.Of course, if you don’t like manually typ<strong>in</strong>g <strong>in</strong> code from books, you can downloadall of the code from the book’s website, <strong>in</strong>clud<strong>in</strong>g extra examples that don’tappear directly <strong>in</strong> the text. All the code works <strong>in</strong> the Express editions of Visual<strong>C#</strong> 2005 and 2008, although of course the examples that are specific to <strong>C#</strong> 3 don’trun <strong>in</strong> Visual <strong>C#</strong> 2005. 8Figure 1.6 Snippy <strong>in</strong> action.The code <strong>in</strong> the top area isconverted <strong>in</strong>to a full program,then run. Its output is shown<strong>in</strong> the bottom area.8Some of them may run <strong>in</strong> Visual Studio 2005 with the <strong>C#</strong> 3 extension Community Technology Preview (CTP)<strong>in</strong>stalled, but I make no guarantees. The language has changed <strong>in</strong> a few ways s<strong>in</strong>ce the f<strong>in</strong>al CTP was released,and I haven’t tested any of the code <strong>in</strong> this environment. Visual <strong>C#</strong> 2008 Express is free, though, so why notgive it a try?Licensed to Rhona Hadida

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!