A C# Programming Tou
- Starting C#
- Creating a New Project
- Understanding the C# Environment
- Changing the Characteristics of Objects
- Naming Objects
- Setting the Text Property of the Form
- Giving the Form an Icon
- Changing the Size of the Form
- Adding Controls to a Form
- Designing an Interface
- Adding an Invisible Control to a Form
- Coding an Interface
- Running a Project
- Summary
- Q&A
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 may 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 activitybuilding confidence. Programming is part art and part science. Although it may 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 the desired result.
In this hour, you'll complete a quick tour that takes you step-by-step through creating a complete, albeit small, C# 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 screenoh, 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, both of which are skills that will come in handy in later applications that you create. Creating large, commercial solutions is accomplished by way of a series of small steps. After you've finished creating this small project, you'll have an overall feel for the development process.
The highlights of this hour include the following:
-
Building a simple, yet functional, 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 StudioC# IDE
I hope that by the end of this hour, you'll realize just how much fun it is to program using C#.
Starting C#
You must become familiar with a few terms before you begin to create programs in C#:
Distributable Component The final, compiled version of a project. Components can be distributed to other people and other computers and do not require C# to run (although the .NET Framework is required, which you'll learn about in coming hours). Distributable components are also called programs. In Hour 22, "Deploying a Solution," 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 may consist of many projects, such as a Windows Application project and support DLL projects.
Solution A collection of projects and files that compose an application or component.
C# is a complete development environment; every tool you'll need to create your C# projects is accessed from within Visual Studio. The Visual Studio-C# environment is called the IDE, short for Integrated Development Environment, and it is the design framework in which you build applications. To work with C# projects, you must first start the Visual Studio IDE.
Start the C# IDE now by choosing Microsoft Visual Studio .NET from within the Microsoft Visual Studio .NET folder on your Start menu.