Computing with C# and the .NET Framework, 2nd Edition

Book description


Thoroughly revised and updated to incorporate Microsoft® Visual Studio® 2010, Computing with C# and the .NET Framework, Second Edition carefully introduces object-oriented and event-driven programming with numerous examples, so students can grasp these difficult concepts and then apply them. Appropriate for the two-term CS1 and introductory C# programming courses, this text takes a spiral approach to teach objects, starting with simple intuitive examples, then simple class design, and progresses to the more difficult aspects of inheritance and polymorphism. Similarly with events, the spiral approach is used to introduce simple paint event first, proceeding to user interfaces and event handlers. The many and varied types of exercises provide students with the practice they need to fully comprehend this popular programming language.

The basics are covered including fundamentals of C#, concepts of object-oriented and event-driven programming, as well as more advanced topics, including data structures, threads, networking, database access, XML, and Web programming. Computing with C# and the .NET Framework, Second Edition is the comprehensive one-volume reference for modern C#-based .NET technology!

New and Key Features of the Second Edition:
-Includes the new and relevant features of the C# language through version 4
-Chapter 12 has been rewritten to use generic collections
-A new section has been added to introduce Language Integrated Query (LINQ)
-Includes named and optional method arguments, anonymous functions, implicity typed local variables, and object and collection initialization
-Contains a new appendix that provides examples showing how to use Visual Studio or Visual C# Express
-Provides numerous and varied exercises to allow the student to assimilate concepts and techniques

Instructor Resources:
-PowerPoint Lecture Outlines
-Solutions to the odd-numbered Programming Exercises
-Chapter Tests
-Source code for all examples in the text

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Table of Contents
  5. Preface
  6. 1 - An Introduction to Computing with C#
    1. 1.1 - Introduction to Computing
      1. Hardware
      2. Software
      3. High-Level Languages
      4. Compilers
      5. Interpreters
      6. Networks
    2. 1.2 - The .NET Framework
      1. The Common Language Runtime
      2. The .NET Framework Class Library
    3. 1.3 - Overview of C#
      1. History
      2. C#'s Features
      3. How C# Works
    4. 1.4 - The Elements of a C# Program
      1. Lexical Structure
      2. Syntax
    5. 1.5 - Compiling andRunning C# Programs
      1. Using the Command Line
      2. Using Visual C# 2010 Express
    6. 1.6 - Developing a C# Program
      1. Levels of Abstraction
      2. The Steps of Software Development
      3. Requirements
      4. Design
      5. Implementation
      6. Testing
      7. Making Improvements
      8. Summary
  7. 2 - C# Progamming Basics
    1. 2.1 - Variables
      1. Identifiers
      2. Keywords
      3. The Character Set
      4. Type int
      5. Initialization
    2. 2.2 - Assignment
      1. Constructing a Simple Program
      2. Constants
    3. 2.3 - Input and Output
      1. Inputting from the Console
      2. Inputting an Integer
      3. Output to the Console
      4. Outputting a Table
    4. 2.4 - Arithmetic Expressions
      1. Precedence of Arithmetic Operators
      2. Combining Assignment and Arithmetic
      3. Increment and Decrement Operators
    5. 2.5 - Methods and Parameters
      1. Methods
      2. Passing by Value
      3. Programming with Methods
      4. Named and Optional Arguments
      5. Summary
      6. Skill Builder Exercises
      7. CriticalThinking Exercises
      8. ProgramDesign Exercises
  8. 3 - Software Engineering with Control Structures
    1. 3.1 - Relational Operators and Expressions
    2. 3.2 - if and if-eise Statements
      1. The if Statement
      2. Control Flow
      3. The if-else Statement
      4. Blocks
    3. 3.3 - The Type double
      1. Scientific Notation
      2. double Values
      3. Output
      4. Input
      5. Mixed-type Expressions
    4. 3.4 - Program Design with the while Loop
      1. Repetition
      2. Planning Programs Using Pseudocode
      3. Loop Termination
      4. Finding the Maximum
    5. 3.5 - Debugging
      1. Getting Information
      2. Testing Carefully
      3. Using the Visual C# Debugger
      4. Summary
      5. Skill Builder Exercises
      6. CriticalThinking Exercises
      7. Debugging Exercise
      8. Program Design Exercises
  9. 4 - More Control Structures and Types
    1. 4.1 - The AND, OR, and NOT Operators
      1. Conditional AND
      2. Conditional OR
      3. Logical Complement
      4. Short-Circuiting
      5. Operator Precedence
      6. Combining AND with OR
    2. 4.2 - Nested if s and the switch Statement
      1. Nested if Statements
      2. Pairing else with if
      3. The switch Statement
    3. 4.3 - The for and do Loops
      1. The for Statement
      2. The do Statement
    4. 4.4 - Additional Primitive Types and Enumerations
      1. The char Type
      2. The long Type
      3. Other Predefined Types
      4. Enumerations
    5. 4.5 - Using the Math Library
      1. Powers and Roots
      2. Maximum, Minimum, and Absolute Value
      3. Floor and Ceiling
      4. Pi and E
    6. 4.6 - Solving Problems with C#: Iterative Development
      1. Defining the Problem
      2. Toward a Solution: The Iterative Process— Develop Pseudocode, a C# Program, and Test
      3. Toward a Solution: First Iteration—Pseudocode, Program, Test
      4. Toward a Solution: Second Iteration—Pseudocode, Program, Test
      5. Completing the C# Code: Third Iteration—Pseudocode, Program, Test
      6. Testing the C# Code
      7. Summary
      8.     Addendum to Chapter 4: IO.cs
      9. Skill Builder Exercises
      10. CriticalThinking Exercises
      11. Debugging Exercise
      12. Program Modification Exercises
      13. Program Design Exercises
  10. 5 - Getting Started with Object-Oriented Programming
    1. 5.1 - The Object Concept
      1. Objects
      2. Using Objects
      3. Defining an Object Type
      4. Instantiating Objects
    2. 5.2 - Introduction to Object-Oriented Design
      1. A Definition
      2. Use Cases and Scenarios
      3. Scenarios for an ATM System
      4. Classification
    3. 5.3 - Classes in C#
      1. The Structure of the BankAccount Class
      2. Instance Variables
      3. Instance Methods
      4. Constructors
    4. 5.4 - Using C# Objects
      1. Reference Types
      2. Creating Objects
      3. Making an Object Behave
      4. Method Overloading
    5. 5.5 - Class Variables and Methods
    6. 5.6 - The QuickFood Example
      1. Class Diagrams
      2. Sequence Diagrams
    7. Summary
    8. Skill Builder Exercises
    9. CriticalThinking Exercises
    10. Debugging Exercise
    11. Program Modification Exercises
    12. Program Design Exercises
  11. 6 - Working with Objects
    1. 6.1 - The string Class
      1. Visualizing a String
      2. Creating a String
      3. String Properties
      4. String Indexers
      5. String Methods
      6. Overloaded Methods
      7. Class Methods
    2. 6.2 - String Operations
      1. Assignment
      2. Equality
      3. Operator Overloading
      4. Comparing Strings
    3. 6.3 - Object Composition
    4. 6.4 - Interfaces
      1. Declaring an Interface
      2. Implementing an Interface
    5. 6.5 - Random Numbers and Simulation
      1. The Random Class
      2. Simulation
      3. Summary
      4. Skill Builder Exercises
      5. CriticalThinking Exercises
      6. Debugging Exercise
      7. Program Modification Exercises
      8. Program Design Exercises
  12. 7 - Arrays
    1. 7.1 - Using Arrays
      1. Changing an Array
    2. 7.2 - Creating, Inputting, and Copying an Array
      1. Array Variables and Values
      2. Creating an Array
      3. Inputting an Array
      4. Copying an Array
    3. 7.3 - Arrays of Objects and a Simulation
      1. Arrays of Objects
      2. A Simulation
    4. 7.4 - Multidimensional Arrays
      1. An Array of Arrays
    5. 7.5 - (Optional) Solving Problems with C#: Insertion Sort
      1. Defining the Problem
      2. Toward a Solution: Developing the Pseudocode
      3. Toward a Solution: Alternatives
      4. Completing the C# Code
      5. Testing the Code
      6. Summary
      7. Skill Builder Exercises
      8. CriticalThinking Exercises
      9. Debugging Exercise
      10. Program Modification Exercises
      11. Program Design Exercises
  13. 8 - Event-Driven Programming
    1. 8.1 - Paint Events
      1. Graphics Mode
      2. Forms
    2. 8.2 - Drawing Shapes
      1. Graphics Drawing
      2. Drawing Relative to the Screen
    3. 8.3 - Drawing Text
      1. Fonts
    4. 8.4 - Using Color
      1. Creating Colors
    5. 8.5 - Mouse and Key Events
      1. Using the Mouse
      2. Using Keys
    6. 8.6 - (Optional) Solving Problems with C#: The Tangram Puzzle
      1. Defining the Problem
      2. Completing the C# Code
      3. Testing the Code
      4. Summary
      5. Skill Builder Exercises
      6. CriticalThinking Exercises
      7. Debugging Exercise
      8. Program Modification Exercises
      9. Program Design Exercises
  14. 9 - User Interfaces
    1. 9.1 - Controls and Event-Handling
      1. The Control Hierarchy
      2. Buttons
      3. Events
      4. Delegates
      5. Anonymous Functions
    2. 9.2 - Using Controls
      1. TextBoxes
      2. Radio Buttons and Combo Boxes
      3. List, Picture, and Check Boxes
      4. StringBuilder
    3. 9.3 - (Optional) Using Visual C#
      1. Creating a Project
    4. 9.4 - (Optional) A GUI for Insertion Sorting
      1. Defining the Problem
      2. Designing a Solution: The Exploratory Process
      3. Designing a Solution: Making a Chart
      4. Designing a Solution: Sorting
      5. Designing a Solution: The User Interface
      6. Completing the C# Code: Making the User Interface Work
      7. Testing the Code
      8. Summary
      9. Skill Builder Exercises
      10. CriticalThinking Exercises
      11. Debugging Exercise
      12. Program Modification Exercises
      13. Program Design Exercises
  15. 10 - Inheritance
    1. 10.1 - Derived Classes
      1. Classification Revisited
      2. Class Hierarchies
      3. Constructing a Derived Class
      4. Adding State and Behavior to a Derived Class
      5. Overriding Behavior
      6. Virtual Methods
      7. The Object Classs
    2. 10.2 - Polymorphism
      1. Polymorphic Operations
      2. Compile-time and Runtime Types
      3. The BankAccount Hierarchy
    3. 10.3 - Abstract Classes
      1. Declaring an Abstract Class
      2. Polymorphism and Abstract Classes
      3. A Shape Class
      4. Line and Circle
    4. 10.4 - Modifiers and Access
      1. Class Visibility
      2. Data Field and Method Visibility
      3. Access to Data Fields
      4. Access to Methods
    5. 10.5 - (Optional) Object-Oriented Design with Use Cases and Scenarios
      1. Defining the Problem
      2. Developing Scenarios
      3. Assigning Responsibilities
      4. Defining the Classes
      5. Completing the C# Code
      6. Testing the Code
      7. Summary
      8. Skill Builder Exercises
      9. CriticalThinking Exercises
      10. Debugging Exercise
      11. Program Modification Exercises
      12. Program Design Exercises
  16. 11 - Exception Handling and Input/ Output
    1. 11.1 - Exception Handling
      1. Program Arguments
      2. Exception Classes
      3. The Index Out of Range Exception
      4. The Format Exception
    2. 11.2 - Text File Input and Output
      1. Reading from a File
      2. Reading Lines and Fields
      3. Writing to a File
    3. 11.3 - Binary Input and Output
      1. The FileInfo Class
      2. Reading and Writing Bytes
      3. Reading and Writing Primitive Types
      4. Random Access Files
    4. 11.4 - Menus and File Dialogs
      1. Summary
      2. Skill Builder Exercises
      3. CriticalThinking Exercises
      4. Debugging Exercise
      5. Program Modification Exercises
      6. Program Design Exercises
  17. 12 - Data Structures
    1. 12.1 - Recursion
      1. Binary Search
      2. Merge Sort
    2. 12.2 - Linked Lists
    3. 12.3 - Stacks and Queues
      1. Stacks
      2. Queues
    4. 12.4 - Collections: ArrayList
      1. Generics
      2. The foreach Statement
      3. Implictly Typed Local Variables
      4. Timing ArrayList Operations
    5. 12.5 - Collections: Dictionary and SortedDictionary
      1. Dictionary
    6. 12.6 - Comparisons and Ordering
      1. Inheriting from Object
      2. Overriding Object Methods
      3. The IComparable Interface
    7. 12.7 - Introduction to LINQ
    8. Summary
    9. Skill Builder Exercises
    10. CriticalThinking Exercises
    11. Debugging Exercise
    12. Program Modification Exercises
    13. Program Design Exercises
  18. 13 - Threads and Animation
    1. 13.1 - Introduction to Threads
      1. The Thread Class
      2. Interrupting Computation
    2. 13.2 - Animation
    3. 13.3 - Images
      1. Double Buffering
    4. 13.4 - Concurrent Programming
      1. An Example Without Synchronization
      2. Synchronization
      3. Attributes
      4. Communication
      5. Deadlock
      6. Summary
    5. Skill Builder Exercises
    6. CriticalThinking Exercises
    7. Debugging Exercise
    8. Program Modification Exercises
    9. Program Design Exercises
  19. 14 - Networking
    1. 14.1 - Requests and Responses
      1. The Uniform Resource Locator (URL)
      2. The Hypertext Transfer Protocol (HTTP)
      3. Connecting from WebClient
      4. Connecting with WebRequest and WebResponse
      5. Using HttpWebRequest and HttpWebResponse
    2. 14.2 - Clients and Servers
      1. Server Ports
      2. Handling HTTP Explicitly
      3. A Client-Server Example
    3. 14.3 - Browsers and Web Servers
      1. A Very Simple Web Browser
      2. A Very Simple Web Server
      3. A Threaded Web Server
    4. 14.4 - Remoting
      1. Distributed Computing
      2. The Interface
      3. The Implementation
      4. The Server
      5. The Client
    5. Summary
    6. Program Modification Exercises
    7. Program Design Exercises
  20. 15 - Using a Database
    1. 15.1 - Database Tables and SQL Queries
      1. Relational Database Tables
      2. Structured Query Language (SQL)
    2. 15.2 - Connecting to a Database
      1. Database and Application Servers
      2. Creating the Database
      3. Connecting from C#
      4. Building the Database
    3. 15.3 - Retrieving Information
      1. Viewing Query Results
      2. SELECT Statement Options
    4. 15.4 - Database Information and Aggregate Functions
      1. Database Information
      2. Creating a Data Set
      3. Aggregate Functions
    5. 15.5 - Stored Procedures and Transactions
      1. Using Stored Procedures
      2. Transaction Processing
    6. 15.6 - A GUI for Database Queries
    7. Summary
    8. Program Modification Exercises
    9. Program Design Exercises
  21. 16 - ASP.NET
    1. 16.1 - HTML
      1. Some HTML Tags
    2. 16.2 - Web Server Controls and Code Behind
      1. Hosting a Web Page
      2. Adding Code to a Web Page
      3. Code Behind
      4. Posting Data
    3. 16.3 - Three-Tiered Architectures
      1. Using a Database in a Three-Tiered Architecture
    4. 16.4 - Session Tracking
    5. Summary
    6. Program Modification Exercises
    7. Program Design Exercises
  22. 17 - XML
    1. 17.1 - XML and Information
      1. The Limitations of HTML
      2. XML Syntax
      3. Schemas
      4. Valid Documents
    2. 17.2 - DOM (Document Object Model) Processing
      1. Building a DOM Tree from an XML File
      2. A Simplified Document and Schema
      3. Checking for Well-Formed and Valid Documents
      4. Building a DOM Tree from Data
    3. 17.3 - XSLT (Extensible Stylesheet Language for Transformations)
      1. Stylesheets
      2. Using Internet Explorer
      3. Using the .NET Framework
      4. Stylesheet Templates
      5. A Stylesheet for the Author Document
      6. Using a Stylesheet
    4. Summary
    5. Program Modification Exercises
    6. Program Design Exercises
  23. A. - Binary and Hexadecimal Numbers
  24. B. - Bitwise and Shift Operators
  25. C. - Operator Precedence Table
  26. D. - The ASCII Character Set
  27. E. - Simple Types
  28. F. - Using Visual Studio or Visual C# Express
  29. Answers to Selected Exercises
  30. Index

Product information

  • Title: Computing with C# and the .NET Framework, 2nd Edition
  • Author(s): Arthur Gittleman
  • Release date: January 2011
  • Publisher(s): Jones & Bartlett Learning
  • ISBN: 9781449615512