Jumping In with Both Feet: A Visual C# 2008 Programming Tour
What You'll Learn in This Hour
- Building a simple (yet functional) Visual C# application
- Letting a user browse a hard drive
- Displaying a picture from a file on disk
- Getting familiar with some programming lingo
- Learning about the Visual Studio .NET IDE
Learning a new programming language can be intimidating. If you've never programmed before, the act of typing seemingly cryptic text to produce sleek and powerful applications probably seems like a black art, and you might wonder how you'll ever learn everything you need to know. The answer is, of course, one step at a time. The first step to learning a language is the same as that of any other activity: building confidence. Programming is part art and part science. Although it might seem like magic, it's more akin to illusion: After you know how things work a lot of the mysticism goes away, freeing you to focus on the mechanics necessary to produce any given desired result.
Producing large, commercial solutions is accomplished by way of a series of small steps. After you've finished creating the project in this hour, you'll have a feel for the overall development process and will have taken the first step toward becoming an accomplished programmer. In fact, you will be building upon this Picture Viewer program in subsequent chapters. By the time you complete this book, you will have built a distributable application, complete with resizable screens, an intuitive interface including menus and toolbars, and robust code with professional error handling. But I'm getting ahead of myself!
In this hour, you'll complete a quick tour that takes you step by step through creating a complete, albeit small, Visual C# program. Most introductory programming books start out with the reader creating a simple Hello World program. I've yet to see a Hello World program that's the least bit helpful (they usually do nothing more than print hello world to the screen—oh, what fun). So, instead, you'll create a picture viewer application that lets you view Windows bitmaps and icons on your computer. You'll learn how to let a user browse for a file and how to display a selected picture file on the screen. The techniques you learn in this chapter will come in handy in many real-world applications that you'll create, but the goal of this chapter is for you to realize just how much fun it is to program with Visual C#.
Starting Visual C# 2008
Before you begin creating programs in Visual C# 2008, you should be familiar with the following terms:
- Distributable component—The final, compiled version of a project. Components can be distributed to other people and other computers, and they don't require the Visual C# 2008 development environment (the tools you use to create a .NET program) to run (although they do require the .NET runtime, which I discuss in Hour 23, "Deploying Applications"). Distributable components are often called programs. In Hour 23, you'll learn how to distribute the Picture Viewer program that you're about to build to other computers.
- Project—A collection of files that can be compiled to create a distributable component (program). There are many types of projects, and complex applications might consist of multiple projects, such as a Windows application project, and support dynamic link library (DLL) projects.
- Solution—A collection of projects and files that make up an application or component.
Visual Studio 2008 is a complete development environment, and it's called the IDE (short for integrated development environment). The IDE is the design framework in which you build applications; every tool you'll need to create your Visual C# projects is accessed from within the Visual C# IDE. Again, Visual Studio 2008 supports development in many different languages—Visual C# being one of the most popular. The environment itself is not Visual C#, but the language you use within Visual Studio 2008 is Visual C#. To work with Visual C# projects, you first start the Visual Studio 2008 IDE.
Start Visual Studio 2008 now by choosing Microsoft Visual C# 2008 Express Edition on your Start/Programs menu. If you are running the full retail version of .NET, your shortcut may have a different name. In this case, locate the shortcut on your Start menu and click it once to start the Visual Studio .NET IDE.