Developers: Learn a New Programming Language or App Development with Deitel LiveLessons Videos!
Login  |  Register  |  Media Kit  |  Press  |  Contact Us  |   Twitter Become a Deitel Fan on Facebook  
Custom Search
AddThis Social Bookmark Button

Tour the Book: C# for Experienced Programmers

In this section, we tour the chapters and appendices of C# for Experienced Programmers. In addition to the topics presented in each chapter, several of the chapters contain an Internet and Web Resources section that lists additional sources from which readers can enhance their knowledge of C# programming. Please and, for updated information and additional learning resources.

Chapter 1 —Introduction to .NET and C#

The first chapter presents the history of the Internet, World Wide Web and various technologies (such as XML and SOAP) that have led to advances in computing. We introduce the Microsoft .NET initiative and the C# programming language, including Web services. We explore the impact of .NET on software development and software reusability. The chapter concludes with a tour of the book.

Chapter 2—Introduction to the Visual Studio® .NET IDE and C# Programming

Chapter 2 introduces Visual Studio .NET, an integrated development environment (IDE) that allows programmers to create C# programs. Visual Studio .NET enables visual programming, in which controls (such as buttons and text boxes) are "dragged" and "dropped" into place, rather than added by typing code. Visual programming increases software-development productivity by eliminating many tedious programming tasks. For example, a graphical user interface’s (GUI’s) properties (information such as size and color) can be modified through the Visual Studio .NET IDE, allowing changes to be made quickly and causing the results to appear immediately on the screen. Rather than having to guess how the GUI will appear while they are writing a program, programmers view the GUI exactly as it will appear when the finished program runs. Visual Studio .NET also contains tools for debugging, documenting and writing code. The chapter presents features of Visual Studio .NET, including its key windows, and shows how to compile and run programs. We use the capabilities of Visual Studio .NET to create a simple Windows application without typing a single line of code. The chapter also introduces readers to non-visual programming in C#. Every concept is presented in the context of a complete working C# program and is followed by one or more screen shots showing actual inputs and outputs as the program executes. This is our Live-Code™ approach. We discuss fundamental tasks, such as how a program inputs data from its users and how to write arithmetic expressions. This chapter also demonstrates displaying text in a window called a MessageBox.

Chapter 3—Control Structures

This chapter introduces the principles of structured programming, a set of techniques that will help the reader develop clear, understandable and maintainable programs. The chapter then introduces the use of control structures that affect the sequence in which statements are executed. Control structures produce programs that are easily understood, debugged and maintained. We discuss the three forms of program control—sequence, selection and repetition—focusing on the if/else, while, for, do/while and switch structures. We explain the break and continue statements and the logical operators. We build on information presented in the previous chapter to create programs that are interactive (i.e., they change their behavior to suit user-supplied inputs). We present an example that combines visual and non-visual programming techniques. This example builds upon the first example presented in Chapter 2.

Chapter 4—Methods and Arrays

A method allows the programmer to create a block of code that can be called upon from various points in a program. Larger programs can be divided into interacting classes, each consisting of methods—this is sometimes called the "divide and conquer" strategy. Programs are divided into simple components that interact in straightforward ways. We discuss how to create our own methods that can take inputs, perform calculations and return outputs. Recursive methods (methods that call themselves) and method overloading, which allows multiple methods to have the same name, are introduced. We demonstrate overloading by creating two Square methods that each take an integer (i.e., a whole number) and a floating-point number (i.e., a number with a decimal point), respectively. This chapter also introduces arrays, our first data structure. Data structures are crucial to storing, sorting, searching and manipulating large amounts of information. Arrays are groups of related data items that allow the programmer to access any element directly. Rather than creating 100 separate variables that are all related in some way, the programmer can create an array of 100 elements and access these elements by their location in the array. We discuss how to declare and allocate arrays, and we build on the techniques of the previous chapter by passing arrays to methods. Chapter 3 provides essential background for the discussion of arrays, because repetition structures are used to iterate through elements in the array. The combination of these concepts helps the reader create highly structured and well-organized programs. We discuss multidimensional arrays (both rectangular and jagged), which can be used to store tables of data. We introduce the foreach structure, which iterates through arrays.

Chapter 5—Object-Based Programming

Chapter 5 introduces objects and classes. Object technology has led to considerable improvements in software development, allowing programmers to create reusable software components. Objects allow programs to be organized in natural and intuitive ways. This chapter presents the fundamentals of object-based programming, such as encapsulation, data abstraction and abstract data types (ADTs). These techniques hide the details of components so that the programmer can concentrate on the "big picture." We create a Time class, which displays the time in standard and universal formats. We show how to create reusable software components with assemblies, namespaces and dynamic link library (DLL) files. We create classes and namespaces, and discuss properties and the readonly and const keywords. This chapter lays the groundwork for the next two chapters, which introduce object-oriented programming.

Chapter 6—Object-Oriented Programming: Inheritance

In this chapter, we discuss inheritance—a form of software reusability in which classes (called derived classes) are created by absorbing attributes and methods of existing classes (called base classes). The inherited class (i.e., the derived class) can contain additional attributes and methods. We show how finding the commonality between classes of objects can reduce the amount of work it takes to build large software systems. A detailed case study demonstrates software reuse and good programming techniques by finding the commonality among a three-level inheritance hierarchy: the Point, Circle and Cylinder classes. We discuss the software engineering benefits of object-oriented programming. Crucial object-oriented programming concepts, such as creating and extending classes, are presented in this chapter.

Chapter 7—Object-Oriented Programming: Polymorphism

Chapter 7 continues our presentation of object-oriented programming. We discuss polymorphic programming and its advantages. Polymorphism permits classes to be treated in a general manner, allowing the same method call to act differently depending on context (e.g., "move" messages sent to a bird and a fish result in dramatically different types of action—a bird flies and a fish swims). In addition to treating existing classes in a general manner, polymorphism allows new classes to be added to a system easily. We identify situations in which polymorphism is useful. A payroll system case study demonstrates polymorphism—the system determines the wages for each employee differently to suit the type of employee (bosses, paid fixed salaries; hourly workers, paid by the hour; commission workers, who receive a base salary plus commission; and piece workers, who are paid per item produced). These programming techniques and those of the previous chapter allow the programmer to create extensible and reusable software components.

Chapter 8—Exception Handling

Exception handling is one of the most important topics in C# from the standpoint of building mission-critical and business-critical applications. Users can enter incorrect data, data can be corrupted and clients can try to access records that do not exist or are restricted. A simple division-by-zero error may cause a calculator program to crash, but what if such an error occurs in the navigation system of an airplane while it is in flight? In some cases, the results of program failure could be disastrous. Programmers need to know how to recognize the errors (exceptions) that could occur in software components and handle those exceptions effectively, allowing programs to deal with problems and continue executing instead of "crashing." Programmers who construct software systems from reusable components built by other programmers must deal with the exceptions that those components may "throw." This chapter covers the details of C# exception handling, the termination model of exception handling, throwing and catching exceptions and FCL class Exception.

Chapter 9—Graphical User Interface Concepts: Part 1

Chapter 9 explains how to add sophisticated GUIs to programs. By using the techniques of rapid application development (RAD), programmers can create GUIs from reusable components, rather than explicitly programming every detail. The Visual Studio .NET IDE makes developing GUIs even easier by allowing the programmer to position components in a window through so-called visual programming. We discuss how to construct user interfaces with Windows Forms controls such as labels, buttons, textboxes and picture boxes. We also introduce events, which are messages sent by a program to signal to an object or a set of objects that an action has occurred. Events most commonly signal user interactions with GUI controls, but also can signal internal actions in a program. We overview event handling and discuss how to handle events specific to controls, the mouse and the keyboard.

Chapter 10—Graphical User Interface Concepts: Part 2

Chapter 10 introduces more complex GUI components, including menus, link labels, panels, list boxes, combo boxes and tab controls. Multiple Document Interface (MDI) programming is presented, which allows multiple documents (i.e., forms) to be open simultaneously in a single GUI. We conclude with an introduction to visual inheritance, which enables programmers to combine the GUI concepts presented in this chapter with the object-oriented concepts presented in Chapter 6 to create user interfaces that can be used and extended by other programmers. Tips are included throughout the chapter to help the programmer create visually appealing, well-organized and consistent GUIs.

Chapter 11—Multithreading

Users have come to expect much from applications. Users want to download files from the Internet, listen to music, print documents and browse the Web—all at the same time! To do this, programmers need a feature called multithreading, which allows applications to perform multiple activities concurrently. The .NET Framework includes built-in capabilities to enable multithreaded applications while shielding programmers from complex details. The .NET languages are better equipped to deal with more sophisticated multimedia, network-based and multiprocessor-based applications than languages that do not have multithreading features. This chapter introduces the FCL’s threading classes and covers threads, thread life-cycles, time-slicing, scheduling and priorities. We analyze the producer-consumer relationship, thread synchronization and circular buffers. This chapter lays the foundation for creating the multithreaded programs that clients demand.

Chapter 12—Strings, Characters and Regular Expressions

In this chapter, we discuss the processing of words, sentences, characters and groups of characters. In C#, strings (groups of characters) are objects. This is yet another benefit of C#’s emphasis on object-oriented programming. Objects of type string contain methods that can copy, search, extract substrings and concatenate strings with one another. We introduce class StringBuilder, which defines string-like objects that can be modified after initialization. As an interesting example of strings, we create a card shuffling-and-dealing simulation. We discuss regular expressions, a powerful tool for searching and manipulating text.

Chapter 13—Graphics and Multimedia

In this chapter, we discuss GDI (an extension of the Graphics Device Interface—GDI), the Windows service that provides the graphical features used by .NET applications. The extensive graphical capabilities of GDI can make programs more visual and fun to create and use. We discuss C#’s treatment of graphics objects and color control. We also discuss how to draw arcs, polygons and other shapes. This chapter also demonstrates how to use various pens and brushes to create color effects and includes an example that demonstrates gradient fills and textures. We also introduce techniques for turning text-only applications into exciting, aesthetically pleasing programs that even novice programmers can write with ease. The second half of the chapter focuses on audio, video and speech technology. We discuss adding sound, video and animated characters to programs (primarily via existing audio and video clips). You will see how easy it is to incorporate multimedia into C# applications. This chapter introduces an exciting technology called Microsoft Agent for adding interactive animated characters to a program. Each character allows users to interact with the application, using more natural human communication techniques, such as speech. The agent characters respond to mouse and keyboard events, speak and hear (i.e., they support speech synthesis and speech recognition). With these capabilities, your applications can speak to users and actually respond to their voice commands!

Chapter 14—Files and Streams

Imagine a program that could not save data to a file. Once the program is closed, all the work performed by the program is lost forever. For this reason, this chapter is one of the most important for programmers who will be developing commercial applications. We introduce FCL classes for inputting and outputting data. A detailed example demonstrates these concepts by allowing users to read and write bank account information to and from files. We introduce the FCL classes and methods that help perform input and output conveniently—they demonstrate the power of object-oriented programming and reusable classes. We discuss benefits of sequential files, random-access files and buffering. This chapter lays the groundwork for the material presented in Chapter 19, Networking: Streams-Based Sockets and Datagrams.

Chapter 15—Extensible Markup Language (XML)

The Extensible Markup Language (XML) derives from SGML (Standard Generalized Markup Language), which became an industry standard in 1986. Although SGML is employed in publishing applications worldwide, it has not been incorporated into the mainstream programming community because of its sheer size and complexity. XML is an effort to make SGML-like technology available to a much broader community. XML, created by the World Wide Web Consortium (W3C), describes data in a portable format. XML differs in concept from markup languages such as HTML, which only describes how information is rendered in a browser. XML is a technology for creating markup languages for virtually any type of information. Document authors use XML to create entirely new markup languages to describe specific types of data, including mathematical formulas, chemical molecular structures, music, recipes and much more. Markup languages created with XML include XHTML (Extensible HyperText Markup Language, for Web content), MathML (for mathematics), VoiceXML™ (for speech), SMIL™ (Synchronized Multimedia Integration Language, for multimedia presentations), CML (Chemical Markup Language, for chemistry) and XBRL (Extensible Business Reporting Language, for financial data exchange). The extensibility of XML has made it one of the most important technologies in industry today and is being integrated into almost every field. Companies and individuals constantly are finding new and innovative uses for XML. In this chapter, we present examples that illustrate the basics of marking up data with XML. We demonstrate several XML-derived markup languages, such as XML Schema (for checking an XML document’s grammar), XSLT (Extensible Stylesheet Language Transformations, for transforming an XML document’s data into another text-based format such as XHTML) and Microsoft’s BizTalk™ (for marking up business transactions). (For readers who are unfamiliar with XHTML, we provide Appendices K and L, which provide a detailed introduction to XHTML.)

Chapter 16—Database, SQL and ADO .NET

Data storage and access are integral to creating powerful software applications. This chapter discusses .NET support for database manipulation. Today's most popular database systems are relational databases. In this chapter, we introduce the Structured Query Language (SQL) for performing queries on relational databases. We also introduce ActiveX Data Objects ADO .NET—an extension of ADO that enables .NET applications to access and manipulate databases. ADO .NET allows data to be exported as XML, which enables applications that use ADO .NET to communicate with a variety of programs that understand XML. We show the reader how to create database connections, using tools provided in Visual Studio .NET, and how to use ADO .NET classes to query a database.

Chapter 17—ASP .NET, Web Forms and Web Controls

Previous chapters demonstrated how to create applications that execute locally on the user’s computer. In this chapter and Chapters 18 and 22, we discuss how to create Web-based applications using Active Server Pages (ASP) .NET. This is a crucial aspect of .NET and of Microsoft’s vision of how software should be developed and deployed on the Internet. ASP .NET is an integral technology for creating dynamic Web content marked up as HTML. (For readers who are unfamiliar with HTML, we provide a detailed introduction in Appendices I and J.) Web Forms provide GUIs for ASP .NET pages and can contain Web controls, such as labels, buttons and textboxes with which users interact. Like Windows Forms, Web Forms are designed using visual programming. This chapter presents many interesting examples, which include an online guest book application and a multi-tier, database-intensive application that allows users to query a database for a list of publications by a specific author. Debugging Web Forms using the Trace property also is discussed.

Chapter 18—ASP .NET and Web Services

Chapter 18 continues our discussion of ASP .NET. In this chapter, we introduce Web services, which are programs that "expose" services (i.e., methods) to clients over the Internet, intranets and extranets. Web services offer increased software reusability by allowing services on disparate platforms to interact with each other seamlessly. This chapter presents several interesting examples that include Web services for manipulating huge numbers (up to 100 digits), simulating the card game of blackjack and implementing an airline reservation system. One particularly interesting example is our temperature server, a Web service that gathers weather information for dozens of cities in the United States.

Chapter 19—Networking: Streams-Based Sockets and Datagrams

Chapter 19 introduces the fundamental techniques of streams-based networking. We demonstrate how streams-based sockets allow programmers to hide many networking details. With sockets, networking is as simple as if the programmer were reading from and writing to a file. We also introduce datagrams, in which packets of information are sent between programs. Each packet is addressed to its recipient and sent out to the network, which routes the packet to its destination. The examples in this chapter focus on communication between applications. One example demonstrates using streams-based sockets to communicate between two C# programs. Another, similar example sends datagrams between applications. We also show how to create a multithreaded-server application that can communicate with multiple clients in parallel. In this client/server tic-tac-toe game, the server maintains the status of the game, and two clients communicate with the server to play the game.

Chapter 20—Data Structures and Collections

This chapter discusses arranging data into aggregations such as linked lists, stacks, queues and trees. Each data structure has properties that are useful in a wide variety of applications, from sorting elements to keeping track of method calls. We discuss how to build each of these data structures. This is also a valuable experience in crafting useful classes. In addition, we cover pre-built collection classes in the FCL. These classes store sets, or collections, of data and provide functionality that allow the developer to sort, insert, delete and retrieve data items. Different collection classes store data in different ways. This chapter focuses on classes Array, ArrayList, Stack and Hashtable, discussing the details of each. When possible, C# programmers should use the FCL to find appropriate data structures, rather than implementing these data structures themselves. This chapter reinforces much of the object technology discussed in Chapters 5–7, including classes, inheritance and composition.

Chapter 21—Accessibility

The World Wide Web presents challenges to individuals with disabilities. Multimedia-rich Web sites are difficult for text readers and other programs to interpret; thus, users with hearing and visual impairments may have difficulty browsing such sites. To help rectify this situation, the World Wide Web Consortium (W3C) launched the Web Accessibility Initiative (WAI), which provides guidelines for making Web sites accessible to people with disabilities. This chapter provides a description of these guidelines, such as the use of the headers element to make tables more accessible to page readers, the alt attribute of the img element to describe images and the combination of XHTML and Cascading Style Sheets (CSS) to ensure that a page can be viewed on almost any type of display or reader. We illustrate key accessibility features of Visual Studio .NET, Internet Explorer and Windows 2000. We also introduce VoiceXML™ and CallXML™, two technologies for increasing the accessibility of Web-based content. VoiceXML helps people with visual impairments to access Web content via speech synthesis and speech recognition. CallXML allows users with visual impairments to access Web-based content through a telephone.

Chapter 22—Mobile Internet Toolkit

The demand for wireless applications is growing rapidly. Within the next two years, the number of people browsing the Web from wireless devices will exceed the number browsing from desktop computers. The Mobile Internet Toolkit (MIT) extends Visual Studio .NET by providing a set of FCL classes for creating Web applications for mobile devices. We introduce mobile Web controls and mobile Web Forms that can be used to create ASP .NET applications that target a wide range of mobile devices. Furthermore, mobile Web applications created using the MIT can be designed to determine the type of device making the request and generate markup appropriate for that specific device. For example, a personal digital assistant and mobile phone can request the same page, but receive different markup. This is known as device-specific rendering, a process demonstrated in this chapter. Finally, we demonstrate how to consume a Web service from a mobile Web application. In this example, we show how similar it is to access a Web service from a mobile application, as it is to access a Web service from a Windows application.

Appendix A—Operator precedence chart

This appendix lists C# operators and their precedence.

Appendix B—Number Systems

This appendix explains the binary, octal, decimal and hexadecimal number systems. It also reviews the conversion of numbers among these bases and illustrates mathematical operations in each base.

Appendix C—Career Opportunities

This appendix provides career resources for C# programmers.

Appendix D—Visual Studio .NET Debugger

This appendix introduces the Visual Studio .NET debugger for locating logic errors in programs. Key features include setting "breakpoints," stepping through programs line-by-line and "watching" variable values.

Appendix E—Generating Documentation in Visual Studio .NET

Appendix E discusses how to use documentation comments within C# programs. Programmers can use Visual Studio .NET’s documentation tool to generate XML- or HTML-formatted documentation.

Appendix F—ASCII Character Set

This appendix contains a table of the 128 ASCII (American Standard Code for Information Interchange) alphanumeric symbols and their corresponding integer values.

Appendix G—Unicode®

This appendix introduces the Unicode Standard, an encoding scheme that assigns unique numeric values to the characters of most of the world’s languages. We include a Windows application that uses Unicode encoding to print welcome messages in several languages.

Appendix H—COM Integration

Prior to .NET, COM (Component Object Model) was critical for specifying how different Windows programming languages communicate at the binary level. For example, COM components such as ActiveX controls and ActiveX DLLs often were written in Microsoft Visual C , but used in other Windows programs. The .NET platform does not directly support COM components, but Microsoft provides tools for the integration of COM components with .NET applications. In this appendix, we explore some of these tools by integrating an ActiveX control and an ActiveX DLL into C# applications.

Appendices I and J—Introduction to HyperText Markup Language 4: 1 & 2

These appendices provide an introduction to HTML—a markup language for describing the elements of a Web page so that a browser, such as Microsoft’s Internet Explorer, can render that page. The reader should be familiar with the contents of these appendices before studying Chapter 17, ASP .NET, Web Forms and Web Controls. No C# programming is presented in these appendices. Some key topics covered in Appendix I include incorporating text and images in an HTML document, linking to other HTML documents on the Web, incorporating special characters (such as copyright and trademark symbols) into an HTML document and separating parts of an HTML document with horizontal lines (called horizontal rules). In Appendix J, we discuss more substantial HTML elements and features. We demonstrate how to present information in lists and tables. We discuss how to collect information from users browsing a site. We explain how to use internal linking and image maps to make Web pages easier to navigate. We also discuss how to use frames to display multiple documents in the browser window.

Appendices K and L—Introduction to XHTML: Parts 1 & 2

In these appendices, we introduce the Extensible HyperText Markup Language (XHTML), an emerging W3C technology designed to replace HTML as the primary means of describing Web content. As an XML-based language, XHTML is more robust and extensible than HTML. XHTML incorporates most of HTML’s elements and attributes—the focus of these appendices. Appendices K and L are included for our readers who do not know XHTML or who would like a review of XHTML before studying Chapter 15, Extensible Markup Language (XML) and Chapter 21, Accessibility.

Appendix M—HTML/XHTML Special Characters

This appendix provides many commonly used HTML/XHTML special characters, called character entity references.

Appendix N—HTML/XHTML Colors

This appendix lists commonly used HTML/XHTML color names and their corresponding hexadecimal values.

Appendix O—Bit Manipulation

This appendix discusses C#’s powerful bit-manipulation capabilities. This helps programs process bit strings, set individual bits on or off and store information more compactly. Such capabilities—inherited from C—are characteristic of low-level assembly languages and are valued by programmers writing systems software, such as operating system and networking software.

Appendix P—Crystal Reports

Visual Studio .NET integrates a special edition of Crystal Reports®—a Windows-based report generator. This appendix presents the resources that Crystal Decisions, the company that produces Crystal Reports, offers on its Web site and overviews Crystal Report’s unique functionality and features in Visual Studio .NET.


Discounts on subscriptions

Java How to Program, 7/e Cover

ISBN: 0130461334
© 2002

Order now at

Additional Resources
Download Code
Examples and
Other Premium
Content for
Registered Users

Login or Register to download this book's code examples and other premium content.

Update :: December 16, 2017