In this chapter, you will learn how to:
Use expressions, variables, and constants.
Use methods.
Use flow control statements.
Handle errors.
Use object-oriented programming techniques.
This chapter is intended for readers who have little or no direct programming experience. It’s designed to give a brief overview of some basic programming concepts that will help you better understand the examples presented throughout the book. Readers with programming experience might wish to skip this chapter and move on to Chapter 4.
Although this chapter provides an overview of basic programming concepts, I encourage readers with little hands-on programming experience to use other resources to supplement this information. These resources include books on programming basics, Web sites such as the Microsoft Developer Network site (http://msdn.microsoft.com), and newsgroups and mailing lists that can be helpful to the inexperienced. (Microsoft maintains a large number of newsgroups on development topics related to Microsoft tools at http://msdn.microsoft.com/newsgroups/. You can read from and post to these newsgroups using a newsreader such as Outlook Express.) And the ASP.NET development team at Microsoft has just launched a set of discussion forums on ASP.NET that promise to be a great resource as well. These forums can be found at http://www.asp.net/forums/. Of course, one of the best (and most overlooked) resources for programming concepts in C# is the MSDN documentation that ships with Microsoft Visual C# .NET (a subset of which is also available as part of the quarterly MSDN library, which can be ordered from http://msdn.microsoft.com/subscription). The MSDN documentation contains samples, tutorials, language references, and specifications for C#, Microsoft Visual Basic .NET, managed extensions for C++, and JScript .NET.
This chapter will discuss how these basic programming concepts apply to ASP.NET, and how you can use them to create effective ASP.NET applications. Although most of these concepts aren’t language-specific, there are some subtle differences in how they’re implemented in C# vs. Visual Basic .NET or other .NET languages.
Note |
In ASP.NET, all code is contained in either Web Forms pages, code- behind modules, or modules that make up class libraries that are external to your ASP.NET applications. The term module in this sense refers to the .cs file that contains the code. A class, as you’ll see in “Using Classes as Containers for Code” later in this chapter, is a special type of code container that provides a number of useful features. Classes are contained within modules (that is, files with the extension .cs). A namespace contains one or more classes and can be defined in one or more modules. Namespaces can be used to prevent name collisions when two classes have the same name. |