All Pages All Books|
|
||||
|
34 Chapter 2 • Introducing C# Programming
Introduction
Let’s start with your first look into the C# language. This chapter teaches you to write, build, and execute console applications. This provides the groundwork for developing applications that use more advanced features of .NET in later chapters.
The C# language is a modern object-oriented language. In some ways, it can be seen as an extension of other languages that came before it. C# is most often compared with Java and C++. If you are not familiar with C# programming, this chapter gets you started. If you are familiar with Java or C++, you may want to just skim this chapter because the concepts presented will look very familiar to you. If you already know C#, feel free to skip this chapter entirely. We assume you have a basic understanding of at least one object-oriented language.
We’ve mentioned that C# is a modern object-oriented language. Let’s take a little time to explain what we mean by that. C# is a modern language. It supports the notion of data types, flow of control statements, operators, arrays, properties, and exceptions. Depending on the language(s) you are accustomed to programming in, most of these concepts should be familiar to you. Throughout the chapter, you will see examples and/or discussions of most of these features of C#.
C# is an object-oriented language. It supports the notion of classes and the object-oriented nature of classes including encapsulation, inheritance, and polymorphism. C# also supports interfaces in conjunction with the .NET Common Language Runtime (CLR) garbage collection, which some feel is necessary in an object-oriented language. It also supports the notion of indexers, which in simplified terms lets you manipulate objects as arrays and delegates, which you can think of as method callbacks on steroids.
The .NET Framework supports console applications, graphical user interface (GUI) applications (Windows Forms), browser-based applications (Web Forms and ASP.NET), and Web Services. This chapter will focus on command line applications, which are known as console applications. Console applications have a text-only user interface. In later chapters, you will learn how to create other types of applications. The focus of this chapter is to explain the concepts that are new and/or different in C# from other object-oriented languages. Concepts that are familiar to object-oriented programmers are covered in brief.
Throughout the chapter, a series of sample programs are presented that illustrate the concepts introduced in each section. The sample programs are available on the CD included with this book. Although there are separate sample programs for each section, each sample builds on concepts covered in earlier sections of this chapter.
|
||||
|
|
||||
|
|
|
|||
|
|
||||
All Pages All Books