0%

Book Description

For all basic-to-intermediate level courses in Visual C# programming.

An informative, engaging, challenging and entertaining introduction to Visual C#

Created by world-renowned programming instructors Paul and Harvey Deitel, Visual C# How to Program, Sixth Edition  introduces  students to the world of desktop, mobile and web app development with Microsoft’s® Visual C#® programming language. Students will use .NET platform and the Visual Studio® Integrated Development Environment to write, test, and debug applications and run them on a wide variety of Windows® devices.

At the heart of the book is the Deitel signature live-code approach—rather than using code snippets, the authors present concepts in the context of complete working programs followed by sample executions. Students begin by getting comfortable with the Visual Studio Community edition IDE and basic C# syntax. Next, they build their skills one step at a time, mastering control structures, classes, objects, methods, variables, arrays, and the core techniques of object-oriented programming. With this strong foundation in place, the authors introduce more sophisticated techniques, including searching, sorting, data structures, generics, and collections. Additional practice is provided through a broad range of example programs and exercises selected from computer science, business, education, social issues, personal utilities, sports, mathematics, puzzles, simulation, game playing, graphics, multimedia and many other areas.

Table of Contents

  1. Visual C#® HOW TO PROGRAM
  2. Deitel® Series Page
  3. Visual C#® HOW TO PROGRAM
  4. Trademarks
  5. Contents
  6. Online Topics
  7. Preface
    1. Contacting the Authors
    2. Join the Deitel & Associates, Inc. Social Media Communities
    3. Object-Oriented Programming with an Early Objects Approach
    4. New C# 6 Features
    5. Interesting, Entertaining and Challenging Exercises
    6. A Tour of the Book
    7. A Tour of the Online Content
    8. Teaching Approach
    9. Obtaining the Software Used in Visual C# How to Program, 6/e
    10. Instructor Supplements
    11. Microsoft DreamSpark™
    12. Reviewers
  8. About Deitel & Associates, Inc.
  9. Before You Begin
  10. 1 Introduction to Computers, the Internet and Visual C#
    1. Objectives
    2. Outline
    3. 1.1 Introduction
    4. 1.2 Computers and the Internet in Industry and Research
    5. 1.3 Hardware and Software
      1. 1.3.1 Moore’s LawMoore’s Law
      2. 1.3.2 Computer Organization
    6. 1.4 Data Hierarchy
    7. 1.5 Machine Languages, Assembly Languages and High-Level Languages
    8. 1.6 Object Technology
    9. 1.7 Internet and World Wide Web
    10. 1.8 C#
      1. 1.8.1 Object-Oriented Programming
      2. 1.8.2 Event-Driven Programming
      3. 1.8.3 Visual Programming
      4. 1.8.4 Generic and Functional Programming
        1. Generic Programming
        2. Functional Programming
      5. 1.8.5 An International Standard
      6. 1.8.6 C# on Non-Windows Platforms
      7. 1.8.7 Internet and Web Programming
      8. 1.8.8 Asynchronous Programming with async and await
      9. 1.8.9 Other Key Programming Languages
    11. 1.9 Microsoft’s .NETMicrosoft’s .NET
      1. 1.9.1 .NET Framework
      2. 1.9.2 Common Language Runtime
      3. 1.9.3 Platform Independence
      4. 1.9.4 Language Interoperability
    12. 1.10 Microsoft’s Windows® Operating SystemMicrosoft’s Windows® Operating System
    13. 1.11 Visual Studio Integrated Development Environment
    14. 1.12 Painter Test-Drive in Visual Studio Community
    15. Self-Review Exercises
    16. Exercises
    17. Making-a-Difference Exercises
    18. Making-a-Difference Resources
  11. 2 Introduction to Visual Studio and Visual Programming
    1. Objectives
    2. Outline
    3. 2.1 Introduction
    4. 2.2 Overview of the Visual Studio Community 2015 IDE
      1. 2.2.1 Introduction to Visual Studio Community 2015
      2. 2.2.2 Visual Studio Themes
      3. 2.2.3 Links on the Start Page
      4. 2.2.4 Creating a New Project
      5. 2.2.5 New Project Dialog and Project Templates
      6. 2.2.6 Forms and Controls
    5. 2.3 Menu Bar and Toolbar
    6. 2.4 Navigating the Visual Studio IDE
      1. 2.4.1 Solution Explorer
      2. 2.4.2 Toolbox
      3. 2.4.3 Properties Window
    7. 2.5 Help Menu and Context-Sensitive Help
    8. 2.6 Visual Programming: Creating a Simple App that Displays Text and an Image
    9. 2.7 Wrap-Up
    10. 2.8 Web Resources
    11. Summary
      1. Section 2.1 Introduction
      2. Section 2.2 Overview of the Visual Studio Community 2015 IDE
      3. Section 2.3 Menu Bar and Toolbar
      4. Section 2.4 Navigating the Visual Studio IDE
      5. Section 2.5 Help Menu and Context-Sensitive Help
      6. Section 2.6 Visual Programming: Creating a Simple App that Displays Text and an Image
    12. Terminology
    13. Self-Review Exercises
    14. Exercises
      1. Note Regarding Exercises 2.7–2.11
  12. 3 Introduction to C# App Programming
    1. Objectives
    2. Outline
    3. 3.1 Introduction
    4. 3.2 Simple App: Displaying a Line of Text
      1. 3.2.1 Comments
      2. 3.2.2 using Directive
      3. 3.2.3 Blank Lines and Whitespace
      4. 3.2.4 Class Declaration
        1. Class Name Convention
        2. Class Declaration’s File Name
        3. Body of a Class Declaration
      5. 3.2.5 Main Method
        1. Body of a Method Declaration
      6. 3.2.6 Displaying a Line of Text
        1. Statements
      7. 3.2.7 Matching Left ({) and Right (}) Braces
    5. 3.3 Creating a Simple App in Visual Studio
      1. 3.3.1 Creating the Console App
      2. 3.3.2 Changing the Name of the App File
      3. 3.3.3 Writing Code and Using IntelliSense
      4. 3.3.4 Compiling and Running the App
      5. 3.3.5 Errors, Error Messages and the Error List Window
    6. 3.4 Modifying Your Simple C# App
      1. 3.4.1 Displaying a Single Line of Text with Multiple Statements
      2. 3.4.2 Displaying Multiple Lines of Text with a Single Statement
    7. 3.5 String Interpolation
    8. 3.6 Another C# App: Adding Integers
      1. 3.6.1 Declaring the int Variable number1
      2. 3.6.2 Declaring Variables number2 and sum
      3. 3.6.3 Prompting the User for Input
      4. 3.6.4 Reading a Value into Variable number1
        1. Possible Erroneous User Input
        2. Assigning a Value to a Variable
      5. 3.6.5 Prompting the User for Input and Reading a Value into number2
      6. 3.6.6 Summing number1 and number2
      7. 3.6.7 Displaying the sum with string Interpolation
      8. 3.6.8 Performing Calculations in Output Statements
    9. 3.7 Memory Concepts
    10. 3.8 Arithmetic
      1. 3.8.1 Arithmetic Expressions in Straight-Line Form
      2. 3.8.2 Parentheses for Grouping Subexpressions
      3. 3.8.3 Rules of Operator Precedence
      4. 3.8.4 Sample Algebraic and C# Expressions
        1. Evaluation of a Second-Degree Polynomial
      5. 3.8.5 Redundant Parentheses
    11. 3.9 Decision Making: Equality and Relational Operators
    12. 3.10 Wrap-Up
    13. Summary
      1. Section 3.2.1 Comments
      2. Section 3.2.2 using Directive
      3. Section 3.2.3 Blank Lines and Whitespace
      4. Section 3.2.4 Class Declaration
      5. Section 3.2.5 Main Method
      6. Section 3.2.6 Displaying a Line of Text
      7. Section 3.3.1 Creating the Console App
      8. Section 3.3.3 Writing Code and Using IntelliSense
      9. Section 3.4.1 Displaying a Single Line of Text with Multiple Statements
      10. Section 3.4.2 Displaying Multiple Lines of Text with a Single Statement
      11. Section 3.5 String Interpolation
      12. Section 3.6.1 Declaring the int Variable number1
      13. Section 3.6.3 Prompting the User for Input
      14. Section 3.6.6 Summing number1 and number2
      15. Section 3.7 Memory Concepts
      16. Section 3.8 Arithmetic
      17. Section 3.8.1 Arithmetic Expressions in Straight-Line Form
      18. Section 3.8.2 Parentheses for Grouping Subexpressions
      19. Section 3.8.3 Rules of Operator Precedence
      20. Section 3.8.5 Redundant Parentheses
      21. Section 3.9 Decision Making: Equality and Relational Operators
    14. Terminology
    15. Self-Review Exercises
    16. Exercises
    17. Making-a-Difference Exercises
  13. 4 Introduction to Classes, Objects, Methods and strings
    1. Objectives
    2. Outline
    3. 4.1 Introduction
    4. 4.2 Test-Driving an Account Class
      1. 4.2.1 Instantiating an Object—Keyword Instantiating an Object—Keyword new
      2. 4.2.2 Calling Class Account’s ’s GetName Method
      3. 4.2.3 Inputting a Name from the User
      4. 4.2.4 Calling Class Account’s ’s SetName Method
        1. Displaying the Name That Was Entered by the User
    5. 4.3 Account Class with an Instance Variable and Set and Get Methods
      1. 4.3.1 Account Class Declaration
      2. 4.3.2 Keyword class and the Class Body
        1. Identifiers and Camel-Case Naming
      3. 4.3.3 Instance Variable name of Type string
        1. null—the Default Initial Value for —the Default Initial Value for string Variables
      4. 4.3.4 SetName Method
        1. SetName’s Parameter’s Parameter
        2. SetName Parameter List
        3. SetName Method Body
        4. Parameters Are Local Variables
      5. 4.3.5 GetName Method
      6. 4.3.6 Access Modifiers private and public
        1. Default Access for Class Members
      7. 4.3.7 Account UML Class Diagram
        1. Top Compartment
        2. Middle Compartment
        3. Bottom Compartment
        4. Return Types
        5. Parameters
    6. 4.4 Creating, Compiling and Running a Visual C# Project with Two Classes
    7. 4.5 Software Engineering with Set and Get Methods
    8. 4.6 Account Class with a Property Rather Than Set and Get Methods
      1. 4.6.1 Class AccountTest Using Account’s Using Account’s Name Property
        1. Invoking Class Account’s ’s Name Property to Get the Name
        2. Invoking Class Account’s ’s Name Property to Set the Name
      2. 4.6.2 Account Class with an Instance Variable and a Property
        1. Property Name’s Declaration’s Declaration
        2. Property Name’s ’s get Accessor
        3. Property Name’s ’s set Accessor
      3. 4.6.3 Account UML Class Diagram with a Property
    9. 4.7 Auto-Implemented Properties
    10. 4.8 Account Class: Initializing Objects with Constructors
      1. 4.8.1 Declaring an Account Constructor for Custom Object Initialization
        1. Account Constructor Declaration
        2. Constructor Body
      2. 4.8.2 Class AccountTest: Initializing Account Objects When They’re Created Objects When They’re Created
        1. Default Constructor
        2. There’s No Default Constructor in a Class That Declares a Constructor
        3. Adding the Constructor to Class Account’s UML Class Diagram’s UML Class Diagram
    11. 4.9 Account Class with a Balance; Processing Monetary Amounts
      1. 4.9.1 Account Class with a decimal balance Instance Variable
        1. Account Class Two-Parameter Constructor
        2. Account Property Balance
        3. set and get Accessors with Different Access Modifiers
        4. Account Class Deposit Method
      2. 4.9.2 AccountTest Class That Uses Account Objects with Balances
        1. Displaying the Account Objects’ Initial Balances Objects’ Initial Balances
        2. string Interpolation Expressions with Formatting
        3. Reading a decimal Value from the User
        4. Making a Deposit
        5. Reading a decimal Value and Depositing into account2
        6. Duplicated Code in Method Main
        7. UML Class Diagram for Class Account
    12. 4.10 Wrap-Up
    13. Summary
      1. Section 4.1 Introduction
      2. Section 4.2 Test-Driving an Account Class
      3. Section 4.2.1 Instantiating an Object—Keyword Instantiating an Object—Keyword new and Constructors
      4. Section 4.2.2 Calling Class Account’s ’s GetName Method
      5. Section 4.2.3 Inputting a Name from the User
      6. Section 4.2.4 Calling Class Account’s ’s SetName Method
      7. Section 4.3 Account Class with an Instance Variable and Set and Get Methods
      8. Section 4.3.1 Account Class Declaration
      9. Section 4.3.2 Keyword class and the Class Body
      10. Section 4.3.3 Instance Variable name of Type string
      11. Section 4.3.4 SetName Method
      12. Section 4.3.5 GetName Method
      13. Section 4.3.6 Access Modifiers private and public
      14. Section 4.3.7 Account UML Class Diagram
      15. Section 4.4 Creating, Compiling and Running a Visual C# Project with Two Classes
      16. Section 4.5 Software Engineering with Set and Get Methods
      17. Section 4.6 Account Class with a Property Rather Than Set and Get Methods
      18. Section 4.6.1 Class AccountTest Using Account’s Using Account’s Name Property
      19. Section 4.6.2 Account Class with an Instance Variable and a Property
      20. Section 4.6.3 Account UML Class Diagram with a Property
      21. Section 4.7 Auto-Implemented Properties
      22. Section 4.8 Account Class: Initializing Objects with Constructors
      23. Section 4.8.1 Declaring an Account Constructor for Custom Object Initialization
      24. Section 4.8.2 Class AccountTest: Initializing Account Objects When They’re Created Objects When They’re Created
      25. Section 4.9 Account Class with a Balance; Processing Monetary Amounts
      26. Section 4.9.1 Account Class with a decimal balance Instance Variable
      27. Section 4.9.2 AccountTest Class That Creates and Uses Account Objects
    14. Terminology
    15. Self-Review Exercises
    16. Exercises
    17. Making-a-Difference Exercises
  14. 5 Algorithm Development and Control Statements: Part 1
    1. Objectives
    2. Outline
    3. 5.1 Introduction
    4. 5.2 Algorithms
    5. 5.3 Pseudocode
    6. 5.4 Control Structures
      1. 5.4.1 Sequence Structure
      2. 5.4.2 Selection Statements
      3. 5.4.3 Iteration Statements
      4. 5.4.4 Summary of Control Statements
    7. 5.5 if Single-Selection Statement
    8. 5.6 if……else Double-Selection Statement
      1. 5.6.1 Nested if……else Statements
      2. 5.6.2 Dangling-else Problem
      3. 5.6.3 Blocks
        1. Syntax and Logic Errors
        2. Empty Statement
      4. 5.6.4 Conditional Operator (?:)
    9. 5.7 Student Class: Nested if……else Statements
    10. 5.8 while Iteration Statement
    11. 5.9 Formulating Algorithms: Counter-Controlled Iteration
      1. 5.9.1 Pseudocode Algorithm with Counter-Controlled Iteration
      2. 5.9.2 Implementing Counter-Controlled Iteration
        1. Local Variables in Main
        2. Initialization Phase: Initializing Variables total and gradeCounter
        3. Processing Phase: Reading 10 Grades from the User
        4. Termination Phase: Calculating and Displaying the Class Average
      3. 5.9.3 Integer Division and Truncation
    12. 5.10 Formulating Algorithms: Sentinel-Controlled Iteration
      1. 5.10.1 Top-Down, Stepwise Refinement: The Top and First Refinement
      2. 5.10.2 Second Refinement
      3. 5.10.3 Implementing Sentinel-Controlled Iteration
      4. 5.10.4 Program Logic for Sentinel-Controlled Iteration
      5. 5.10.5 Braces in a while Statement
      6. 5.10.6 Converting Between Simple Types Explicitly and Implicitly
        1. Cast Operator
        2. Promotions
        3. Cast Operators for Any Type
      7. 5.10.7 Formatting Floating-Point Numbers
        1. Rounding Floating-Point Numbers
    13. 5.11 Formulating Algorithms: Nested Control Statements
      1. 5.11.1 Problem Statement
        1. Problem Statement Observations
      2. 5.11.2 Top-Down, Stepwise Refinement: Pseudocode Representation of the Top
      3. 5.11.3 Top-Down, Stepwise Refinement: First Refinement
      4. 5.11.4 Top-Down, Stepwise Refinement: Second Refinement
      5. 5.11.5 Complete Second Refinement of the Pseudocode
      6. 5.11.6 App That Implements the Pseudocode Algorithm
    14. 5.12 Compound Assignment Operators
    15. 5.13 Increment and Decrement Operators
      1. 5.13.1 Prefix Increment vs. Postfix Increment
      2. 5.13.2 Simplifying Increment Statements
      3. 5.13.3 Operator Precedence and Associativity
    16. 5.14 Simple Types
    17. 5.15 Wrap-Up
    18. Summary
      1. Section 5.2 Algorithms
      2. Section 5.3 Pseudocode
      3. Section 5.4 Control Structures
      4. Section 5.4.1 Sequence Structure
      5. Section 5.4.2 Selection Statements
      6. Section 5.4.3 Iteration Statements
      7. Section 5.4.4 Summary of Control Statements
      8. Section 5.5 if Single-Selection Statement
      9. Section 5.6 if……else Double-Selection Statement
      10. Section 5.6.3 Blocks
      11. Section 5.6.4 Conditional Operator (?:)
      12. Section 5.7 Student Class: Nested if……else Statements
      13. Section 5.8 while Iteration Statement
      14. Section 5.9.1 Pseudocode Algorithm with Counter-Controlled Iteration
      15. Section 5.9.2 Implementing Counter-Controlled Iteration
      16. Section 5.9.3 Integer Division and Truncation
      17. Section 5.10 Formulating Algorithms: Sentinel-Controlled Iteration
      18. Section 5.10.1 Top-Down, Stepwise Refinement: The Top and First Refinement
      19. Section 5.10.2 Second Refinement
      20. Section 5.10.3 Implementing Sentinel-Controlled Iteration
      21. Section 5.10.6 Converting Between Simple Types Explicitly and Implicitly
      22. Section 5.10.7 Formatting Floating-Point Numbers
      23. Section 5.12 Compound Assignment Operators
      24. Section 5.13 Increment and Decrement Operators
      25. Section 5.14 Simple Types
    19. Terminology
    20. Self-Review Exercises
    21. Exercises
    22. Making-a-Difference Exercises
  15. 6 Control Statements: Part 2
    1. Objectives
    2. Outline
    3. 6.1 Introduction
    4. 6.2 Essentials of Counter-Controlled Iteration
    5. 6.3 for Iteration Statement
      1. 6.3.1 A Closer Look at the for Statement’s Header Statement’s Header
      2. 6.3.2 General Format of a for Statement
      3. 6.3.3 Scope of a for Statement’s Control Variable Statement’s Control Variable
      4. 6.3.4 Expressions in a for Statement’s Header Are Optional Statement’s Header Are Optional
      5. 6.3.5 Placing Arithmetic Expressions in a for Statement’s Header Statement’s Header
      6. 6.3.6 Using a for Statement’s Control Variable in the Statement’s Body Statement’s Control Variable in the Statement’s Body
      7. 6.3.7 UML Activity Diagram for the for Statement
    6. 6.4 Examples Using the for Statement
    7. 6.5 App: Summing Even Integers
    8. 6.6 App: Compound-Interest Calculations
      1. 6.6.1 Performing the Interest Calculations with Math Method pow
      2. 6.6.2 Formatting with Field Widths and Alignment
      3. 6.6.3 Caution: Do Not Use float or double for Monetary Amounts
        1. Applications of Floating-Point Numbers
        2. A Warning About Displaying Rounded Values
    9. 6.7 do……while Iteration Statement
    10. 6.8 switch Multiple-Selection Statement
      1. 6.8.1 Using a switch Statement to Count A, B, C, D and F Grades
        1. Reading Grades from the User
        2. Processing the Grades
        3. The switch Statement
        4. Consecutive case Labels
        5. The default Case
        6. No “Fall Through” in the C# switch Statement
        7. Displaying the Grade Report
      2. 6.8.2 switch Statement UML Activity Diagram
      3. 6.8.3 Notes on the Expression in Each case of a switch
    11. 6.9 Class AutoPolicy Case Study: strings in switch Statements
    12. 6.10 break and continue Statements
      1. 6.10.1 break Statement
      2. 6.10.2 continue Statement
    13. 6.11 Logical Operators
      1. 6.11.1 Conditional AND (&&) Operator
      2. 6.11.2 Conditional OR (||) Operator
      3. 6.11.3 Short-Circuit Evaluation of Complex Conditions
      4. 6.11.4 Boolean Logical AND (&) and Boolean Logical OR (|) Operators
      5. 6.11.5 Boolean Logical Exclusive OR (^)
      6. 6.11.6 Logical Negation (!) Operator
      7. 6.11.7 Logical Operators Example
        1. Precedence and Associativity of the Operators Presented So Far
    14. 6.12 Structured-Programming Summary
    15. 6.13 Wrap-Up
    16. Summary
      1. Section 6.2 Essentials of Counter-Controlled Iteration
      2. Section 6.3 for Iteration Statement
      3. Section 6.3.1 A Closer Look at the for Statement’s Header Statement’s Header
      4. Section 6.3.2 General Format of a for Statement
      5. Section 6.3.3 Scope of a for Statement’s Control Variable Statement’s Control Variable
      6. Section 6.3.5 Placing Arithmetic Expressions in a for Statement’s Header Statement’s Header
      7. Section 6.6 App: Compound-Interest Calculations
      8. Section 6.6.1 Performing the Interest Calculations with Math Method pow
      9. Section 6.6.2 Formatting with Field Widths and Alignment
      10. Section 6.6.3 Caution: Do Not Use float or double for Monetary Amounts
      11. Section 6.7 do……while Iteration Statement
      12. Section 6.8 switch Multiple-Selection Statement
      13. Section 6.8.1 Using a switch Statement to Count A, B, C, D and F Grades.
      14. Section 6.10.1 break Statement
      15. Section 6.10.2 continue Statement
      16. Section 6.11 Logical Operators
      17. Section 6.11.1 Conditional AND (&&) Operator
      18. Section 6.11.2 Conditional OR (||) Operator
      19. Section 6.11.3 Short-Circuit Evaluation of Complex Conditions
      20. Section 6.11.4 Boolean Logical AND (&) and Boolean Logical OR (|) Operators
      21. Section 6.11.5 Boolean Logical Exclusive OR (^)
      22. Section 6.11.6 Logical Negation (!) Operator
      23. Section 6.12 Structured-Programming Summary
    17. Terminology
    18. Self-Review Exercises
    19. Exercises
    20. Making-a-Difference Exercises
  16. 7 Methods: A Deeper Look
    1. Objectives
    2. Outline
    3. 7.1 Introduction
    4. 7.2 Packaging Code in C#
      1. 7.2.1 Modularizing Programs
      2. 7.2.2 Calling Methods
    5. 7.3 static Methods, static Variables and Class Math
      1. 7.3.1 Math Class Methods
      2. 7.3.2 Math Class Constants PI and E
      3. 7.3.3 Why Is Main Declared static?
      4. 7.3.4 Additional Comments About Main
    6. 7.4 Methods with Multiple Parameters
      1. 7.4.1 Keyword static
      2. 7.4.2 Method Maximum
        1. Logic of Determining the Maximum Value
      3. 7.4.3 Assembling strings with Concatenation
        1. Anything Can Be Converted to a string
        2. Formatting strings with string Interpolation
      4. 7.4.4 Breaking Apart Large string Literals
      5. 7.4.5 When to Declare Variables as Fields
      6. 7.4.6 Implementing Method Maximum by Reusing Method Math.Max
    7. 7.5 Notes on Using Methods
      1. Three Ways to Call a Method
        1. Three Ways to Return from a Method
        2. static Members Can Access Only the Class’s Other Members Can Access Only the Class’s Other static Members Directly
    8. 7.6 Argument Promotion and Casting
      1. 7.6.1 Promotion Rules
      2. 7.6.2 Sometimes Explicit Casts Are Required
    9. 7.7 The .NET Framework Class Library
    10. 7.8 Case Study: Random-Number Generation
      1. 7.8.1 Creating an Object of Type Random
      2. 7.8.2 Generating a Random Integer
      3. 7.8.3 Scaling the Random-Number Range
      4. 7.8.4 Shifting Random-Number Range
      5. 7.8.5 Combining Shifting and Scaling
      6. 7.8.6 Rolling a Six-Sided Die
        1. Rolling a Six-Sided Die 60,000,000 Times
      7. 7.8.7 Scaling and Shifting Random Numbers
      8. 7.8.8 Repeatability for Testing and Debugging
    11. 7.9 Case Study: A Game of Chance; Introducing Enumerations
      1. 7.9.1 Method RollDice
      2. 7.9.2 Method Main’s Local Variables’s Local Variables
      3. 7.9.3 enum Type Status
      4. 7.9.4 The First Roll
      5. 7.9.5 enum Type DiceNames
      6. 7.9.6 Underlying Type of an enum
      7. 7.9.7 Comparing Integers and enum Constants
        1. Additional Rolls of the Dice
        2. Control Statements in the Craps Example
        3. Code Snippets for Auto-Implemented Properties
    12. 7.10 Scope of Declarations
    13. 7.11 Method-Call Stack and Activation Records
      1. 7.11.1 Method-Call Stack
      2. 7.11.2 Stack Frames
      3. 7.11.3 Local Variables and Stack Frames
      4. 7.11.4 Stack Overflow
      5. 7.11.5 Method-Call Stack in Action
    14. 7.12 Method Overloading
      1. 7.12.1 Declaring Overloaded Methods
      2. 7.12.2 Distinguishing Between Overloaded Methods
      3. 7.12.3 Return Types of Overloaded Methods
    15. 7.13 Optional Parameters
    16. 7.14 Named Parameters
    17. 7.15 C# 6 Expression-Bodied Methods and Properties
    18. 7.16 Recursion
      1. 7.16.1 Base Cases and Recursive Calls
      2. 7.16.2 Recursive Factorial Calculations
      3. 7.16.3 Implementing Factorial Recursively
    19. 7.17 Value Types vs. Reference Types
    20. 7.18 Passing Arguments By Value and By Reference
      1. 7.18.1 ref and out Parameters
        1. ref Parameters
        2. out Parameters
        3. Passing Reference-Type Variables by Reference
      2. 7.18.2 Demonstrating ref, out and Value Parameters
    21. 7.19 Wrap-Up
    22. Summary
      1. Section 7.1 Introduction
      2. Section 7.2 Packaging Code in C#
      3. Section 7.2.1 Modularizing Programs
      4. Section 7.3 static Methods, static Variables and Class Math
      5. Section 7.3.1 Math Class Methods
      6. Section 7.3.2 Math Class Constants PI and E
      7. Section 7.3.4 Additional Comments About Main
      8. Section 7.4.2 Method Maximum
      9. Section 7.4.3 Assembling strings with Concatenation
      10. Section 7.4.4 Breaking Apart Large string Literals
      11. Section 7.5 Notes on Declaring and Using Methods
      12. Section 7.6 Argument Promotion and Casting
      13. Section 7.6.1 Promotion Rules
      14. Section 7.6.2 Sometimes Explicit Casts Are Required
      15. Section 7.7 The .NET Framework Class Library
      16. Section 7.8.2 Generating a Random Integer
      17. Section 7.8.3 Scaling the Random-Number Range
      18. Section 7.8.8 Repeatability for Testing and Debugging
      19. Section 7.9.3 enum Type Status
      20. Section 7.9.5 enum Type DiceNames
      21. Section 7.9.6 Underlying Type of an enum
      22. Section 7.10 Scope of Declarations
      23. Section 7.11 Method-Call Stack and Activation Records
      24. Section 7.11.1 Method-Call Stack
      25. Section 7.11.2 Stack Frames
      26. Section 7.11.3 Local Variables and Stack Frames
      27. Section 7.11.4 Stack Overflow
      28. Section 7.12.1 Declaring Overloaded Methods
      29. Section 7.12.2 Distinguishing Between Overloaded Methods
      30. Section 7.12.3 Return Types of Overloaded Methods
      31. Section 7.13 Optional Parameters
      32. Section 7.14 Named Parameters
      33. Section 7.15 C# 6 Expression-Bodied Methods and Properties
      34. Section 7.16 Recursion
      35. Section 7.16.1 Base Cases and Recursive Calls
      36. Section 7.16.2 Recursive Factorial Calculations
      37. Section 7.17 Value Types vs. Reference Types
      38. Section 7.18 Passing Arguments by Value and by Reference
      39. Section 7.18.1 ref and out Parameters
    23. Terminology
    24. Self-Review Exercises
    25. Exercises
    26. Making-a-Difference Exercises
  17. 8 Arrays; Introduction to Exception Handling
    1. Objectives
    2. Outline
    3. 8.1 Introduction
    4. 8.2 Arrays
    5. 8.3 Declaring and Creating Arrays
    6. 8.4 Examples Using Arrays
      1. 8.4.1 Creating and Initializing an Array
      2. 8.4.2 Using an Array Initializer
      3. 8.4.3 Calculating a Value to Store in Each Array Element
        1. Declaring a Named Constant with const
      4. 8.4.4 Summing the Elements of an Array
      5. 8.4.5 Iterating Through Arrays with foreach
        1. foreach vs. for
      6. 8.4.6 Using Bar Charts to Display Array Data Graphically; Introducing Type Inference with var
        1. Implicitly Typed Local Variables and Keyword var
        2. More on Implicitly Typed Local Variables
      7. 8.4.7 Using the Elements of an Array as Counters
    7. 8.5 Using Arrays to Analyze Survey Results; Intro to Exception Handling
      1. 8.5.1 Summarizing the Results
      2. 8.5.2 Exception Handling: Processing the Incorrect Response
      3. 8.5.3 The try Statement
      4. 8.5.4 Executing the catch Block
      5. 8.5.5 Message Property of the Exception Parameter
    8. 8.6 Case Study: Card Shuffling and Dealing Simulation
      1. 8.6.1 Class Card and Getter-Only Auto-Implemented Properties
      2. 8.6.2 Class DeckOfCards
        1. Class DeckOfCards: Constructor
        2. Class DeckOfCards: Shuffle Method
        3. Recommendation: Use an Unbiased Shuffling Algorithm
        4. Class DeckOfCards: DealCard Method
      3. 8.6.3 Shuffling and Dealing Cards
    9. 8.7 Passing Arrays and Array Elements to Methods
    10. 8.8 Case Study: GradeBook Using an Array to Store Grades
    11. 8.9 Multidimensional Arrays
      1. 8.9.1 Rectangular Arrays
        1. Array-Access Expression for a Two-Dimensional Rectangular Array
        2. Array Initializer for a Two-Dimensional Rectangular Array
      2. 8.9.2 Jagged Arrays
        1. Array Initializer for a Two-Dimensional Jagged Array
        2. Diagram of a Two-Dimensional Jagged Array in Memory
        3. Creating Two-Dimensional Arrays with Array-Creation Expressions
      3. 8.9.3 Two-Dimensional Array Example: Displaying Element Values
        1. Overloaded Method OutputArray
        2. Method OutputArray for Rectangular Arrays
        3. Method OutputArray for Jagged Arrays
        4. Common Multidimensional-Array Manipulations Performed with for Statements
    12. 8.10 Case Study: GradeBook Using a Rectangular Array
    13. 8.11 Variable-Length Argument Lists
    14. 8.12 Using Command-Line Arguments
    15. 8.13 (Optional) Passing Arrays by Value and by Reference
    16. 8.14 Wrap-Up
    17. Summary
      1. Section 8.1 Introduction
      2. Section 8.2 Arrays
      3. Section 8.3 Declaring and Creating Arrays
      4. Section 8.4.2 Using an Array Initializer
      5. Section 8.4.3 Calculating a Value to Store in Each Array Element
      6. Section 8.4.5 Iterating Through Arrays with foreach
      7. Section 8.4.6 Using Bar Charts to Display Array Data Graphically; Introducing Type Inference with var
      8. Section 8.5.2 Exception Handling: Processing the Incorrect Response
      9. Section 8.5.3 The try Statement
      10. Section 8.5.4 Executing the catch Block
      11. Section 8.5.5 Message Property of the Exception Parameter
      12. Section 8.6.1 Class Card and Getter-Only Auto-Implemented Properties
      13. Section 8.7 Passing Arrays and Array Elements to Methods
      14. Section 8.9 Multidimensional Arrays
      15. Section 8.10 Case Study: GradeBook Using a Rectangular Array
      16. Section 8.11 Variable-Length Argument Lists
      17. Section 8.12 Using Command-Line Arguments
      18. Section 8.13 (Optional) Passing Arrays by Value and by Reference
    18. Terminology
    19. Self-Review Exercises
    20. Exercises
    21. Special Section: Building Your Own Computer
    22. Making-a-Difference Exercise
  18. 9 Introduction to LINQ and the List Collection
    1. Objectives
    2. Outline
    3. 9.1 Introduction
    4. 9.2 Querying an Array of int Values Using LINQ
      1. 9.2.1 The from Clause
        1. Implicitly Typed Local Variables
      2. 9.2.2 The where Clause
      3. 9.2.3 The select Clause
      4. 9.2.4 Iterating Through the Results of the LINQ Query
        1. LINQ vs. Iteration Statements
      5. 9.2.5 The orderby Clause
      6. 9.2.6 Interface IEnumerable<T>
    5. 9.3 Querying an Array of Employee Objects Using LINQ
      1. 9.3.1 Accessing the Properties of a LINQ Query’s Range VariableAccessing the Properties of a LINQ Query’s Range Variable
      2. 9.3.2 Sorting a LINQ Query’s Results by Multiple PropertiesSorting a LINQ Query’s Results by Multiple Properties
      3. 9.3.3 Any, First and Count Extension Methods
      4. 9.3.4 Selecting a Property of an Object
      5. 9.3.5 Creating New Types in the select Clause of a LINQ Query
        1. Projections
        2. Changing the Names of Properties in Anonymous Types
    6. 9.4 Introduction to Collections
      1. 9.4.1 List<T> Collection
      2. 9.4.2 Dynamically Resizing a List<T> Collection
        1. Adding and Inserting Elements
        2. Count and Capacity
        3. Iterating Through a List’s Contents
        4. Adding More Elements and Growing the List
        5. Removing Elements
        6. Determining Whether an Element Is in the List
        7. Adding More Elements and Growing the List
        8. Doubling the Capacity
    7. 9.5 Querying the Generic List Collection Using LINQ
      1. 9.5.1 The let Clause
      2. 9.5.2 Deferred Execution
      3. 9.5.3 Extension Methods ToArray and ToList
      4. 9.5.4 Collection Initializers
    8. 9.6 Wrap-Up
    9. 9.7 Deitel LINQ Resource Center
    10. Summary
      1. Section 9.1 Introduction
      2. Section 9.2 Querying an Array of int Values Using LINQ
      3. Section 9.2.1 The from Clause
      4. Section 9.2.2 The where Clause
      5. Section 9.2.3 The select Clause
      6. Section 9.2.4 Iterating Through the Results of the LINQ Query
      7. Section 9.2.5 The orderby Clause
      8. Section 9.2.6 Interface IEnumerable<T>
      9. Section 9.3 Querying an Array of Employee Objects Using LINQ
      10. Section 9.3.2 Sorting a LINQ Query’s Results by Multiple PropertiesSorting a LINQ Query’s Results by Multiple Properties
      11. Section 9.3.3 Any, First and Count Extension Methods
      12. Section 9.3.4 Selecting a Property of an Object
      13. Section 9.3.5 Creating New Types in the select Clause of a LINQ Query
      14. Section 9.4 Introduction to Collections
      15. Section 9.4.1 List<T> Collection
      16. Section 9.5 Querying the Generic List Collection Using LINQ
      17. Section 9.5.1 The let Clause
      18. Section 9.5.2 Deferred Execution
      19. Section 9.5.3 Extension Methods ToArray and ToList
      20. Section 9.5.4 Collection Initializers
    11. Terminology
    12. Self-Review Exercises
    13. Exercises
  19. 10 Classes and Objects: A Deeper Look
    1. Objectives
    2. Outline
    3. 10.1 Introduction
    4. 10.2 Time Class Case Study; Throwing Exceptions
      1. 10.2.1 Time1 Class Declaration
        1. public Class
        2. Method SetTime and Throwing Exceptions
        3. Method ToUniversalString
        4. Method ToString
      2. 10.2.2 Using Class Time1
      3. Calling Time Method SetTime with Invalid Values
      4. Notes on the Time1 Class Declaration
    5. 10.3 Controlling Access to Members
    6. 10.4 Referring to the Current Object’s Members with the Referring to the Current Object’s Members with the this Reference
    7. 10.5 Time Class Case Study: Overloaded Constructors
      1. 10.5.1 Class Time2 with Overloaded Constructors
        1. Class Time2’s Three-Argument Constructor’s Three-Argument Constructor
        2. Constructor Initializers
        3. SetTime Method and the Hour, Minute and Second Properties
        4. Notes Regarding Class Time2’s Methods, Properties and Constructors’s Methods, Properties and Constructors
      2. 10.5.2 Using Class Time2’s Overloaded Constructors’s Overloaded Constructors
    8. 10.6 Default and Parameterless Constructors
    9. 10.7 Composition
      1. 10.7.1 Class Date
        1. Constructor
        2. private set Accessors
      2. 10.7.2 Class Employee
      3. 10.7.3 Class EmployeeTest
    10. 10.8 Garbage Collection and Destructors
    11. 10.9 static Class Members
    12. 10.10 readonly Instance Variables
    13. 10.11 Class View and Object Browser
      1. 10.11.1 Using the Class View Window
      2. 10.11.2 Using the Object Browser
    14. 10.12 Object Initializers
    15. 10.13 Operator Overloading; Introducing struct
      1. 10.13.1 Creating Value Types with struct
        1. When to Declare a struct Type
      2. 10.13.2 Value Type ComplexNumber
        1. Constructor
        2. Overloaded Operators
      3. 10.13.3 Class ComplexTest
    16. 10.14 Time Class Case Study: Extension Methods
    17. 10.15 Wrap-Up
    18. Summary
      1. Section 10.2.1 Time1 Class Declaration
      2. Section 10.2.2 Using Class Time1
      3. Section 10.3 Controlling Access to Members
      4. Section 10.4 Referring to the Current Object’s Members with the Referring to the Current Object’s Members with the this Reference
      5. Section 10.5 Time Class Case Study: Overloaded Constructors
      6. Section 10.5.1 Class Time2 with Overloaded Constructors
      7. Section 10.6 Default and Parameterless Constructors
      8. Section 10.7 Composition
      9. Section 10.8 Garbage Collection and Destructors
      10. Section 10.9 static Class Members
      11. Section 10.10 readonly Instance Variables
      12. Section 10.11.1 Using the Class View Window
      13. Section 10.11.2 Using the Object Browser
      14. Section 10.12 Object Initializers
      15. Section 10.13 Operator Overloading; Introducing struct
      16. Section 10.13.1 Creating Value Types with struct
      17. Section 10.13.2 Value Type ComplexNumber
      18. Section 10.14 Time Class Case Study: Extension Methods
    19. Terminology
    20. Self-Review Exercises
    21. Exercises
  20. 11 Object-Oriented Programming: Inheritance
    1. Objectives
    2. Outline
    3. 11.1 Introduction
    4. 11.2 Base Classes and Derived Classes
    5. 11.3 protected Members
    6. 11.4 Relationship between Base Classes and Derived Classes
      1. 11.4.1 Creating and Using a CommissionEmployee Class
        1. CommissionEmployee Class Overview
        2. CommissionEmployee Constructor
        3. CommissionEmployee Method Earnings
        4. CommissionEmployee Method ToString
        5. Class CommissionEmployeeTest
      2. 11.4.2 Creating a BasePlusCommissionEmployee Class without Using Inheritance
        1. Class BasePlusCommissionEmployeeTest
        2. Code Duplication
      3. 11.4.3 Creating a CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy
        1. A Derived Class’s Constructor Must Call Its Base Class’s Constructor
        2. BasePlusCommissionEmployee Method Earnings
      4. 11.4.4 CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
        1. Class BasePlusCommissionEmployee
        2. Testing Class BasePlusCommissionEmployee
        3. public vs. protected Data
        4. Problems with protected Instance Variables
      5. 11.4.5 CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
        1. Base Class CommissionEmployee
        2. Derived Class BasePlusCommissionEmployee
        3. BasePlusCommissionEmployee Method Earnings
        4. BasePlusCommissionEmployee Method ToString
        5. Testing Class BasePlusCommissionEmployee
    7. 11.5 Constructors in Derived Classes
    8. 11.6 Software Engineering with Inheritance
    9. 11.7 Class object
    10. 11.8 Wrap-Up
    11. Summary
      1. Section 11.1 Introduction
      2. Section 11.2 Base Classes and Derived Classes
      3. Section 11.3 protected Members
      4. Section 11.4.1 Creating and Using a CommissionEmployee Class
      5. Section 11.4.2 Creating a BasePlusCommissionEmployee Class without Using Inheritance
      6. Section 11.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
      7. Section 11.4.4CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
      8. Section 11.4.5CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
      9. Section 11.5 Constructors in Derived Classes
      10. Section 11.6 Software Engineering with Inheritance
      11. Section 11.7 Class object
    12. Terminology
    13. Self-Review Exercises
    14. Exercises
  21. 12 OOP: Polymorphism and Interfaces
    1. Objectives
    2. Outline
    3. 12.1 Introduction
    4. 12.2 Polymorphism Examples
    5. 12.3 Demonstrating Polymorphic Behavior
    6. 12.4 Abstract Classes and Methods
    7. 12.5 Case Study: Payroll System Using Polymorphism
      1. 12.5.1 Creating Abstract Base Class Employee
        1. Class Employee
      2. 12.5.2 Creating Concrete Derived Class SalariedEmployee
      3. 12.5.3 Creating Concrete Derived Class HourlyEmployee
      4. 12.5.4 Creating Concrete Derived Class CommissionEmployee
      5. 12.5.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
      6. 12.5.6 Polymorphic Processing, Operator is and Downcasting
        1. Assigning Derived-Class Objects to Base-Class References
        2. Polymorphic Processing of Employees
        3. Giving BasePlusCommissionEmployees 10% Raises
        4. Every Object Knows Its Own Type
        5. Avoiding Compilation Errors with Downcasting
      7. 12.5.7 Summary of the Allowed Assignments Between Base-Class and Derived-Class Variables
    8. 12.6 sealed Methods and Classes
    9. 12.7 Case Study: Creating and Using Interfaces
      1. 12.7.1 Developing an IPayable Hierarchy
        1. UML Diagram Containing an Interface
      2. 12.7.2 Declaring Interface IPayable
      3. 12.7.3 Creating Class Invoice
      4. 12.7.4 Modifying Class Employee to Implement Interface IPayable
        1. Derived Classes of Employee and Interface IPayable
      5. 12.7.5 Using Interface IPayable to Process Invoices and Employees Polymorphically
      6. 12.7.6 Common Interfaces of the .NET Framework Class Library
    10. 12.8 Wrap-Up
    11. Summary
      1. Section 12.1 Introduction
      2. Section 12.2 Polymorphism Examples
      3. Section 12.3 Demonstrating Polymorphic Behavior
      4. Section 12.4 Abstract Classes and Methods
      5. Section 12.5 Case Study: Payroll System Using Polymorphism
      6. Section 12.6 sealed Methods and Classes
      7. Section 12.7 Case Study: Creating and Using Interfaces
    12. Terminology
    13. Self-Review Exercises
    14. Exercises
    15. Making-a-Difference Exercise
  22. 13 Exception Handling: A Deeper Look
    1. Objectives
    2. Outline
    3. 13.1 Introduction
    4. 13.2 Example: Divide by Zero without Exception Handling
      1. 13.2.1 Dividing By Zero
      2. 13.2.2 Enter a Non-Numeric Denominator
      3. 13.2.3 Unhandled Exceptions Terminate the App
    5. 13.3 Example: Handling DivideByZeroExceptions and FormatExceptions
      1. Sample Outputs
      2. Another Way to Convert Strings to Integers
      3. 13.3.1 Enclosing Code in a try Block
      4. 13.3.2 Catching Exceptions
      5. 13.3.3 Uncaught Exceptions
      6. 13.3.4 Termination Model of Exception Handling
      7. 13.3.5 Flow of Control When Exceptions Occur
    6. 13.4 .NET Exception Hierarchy
      1. 13.4.1 Class SystemException
      2. 13.4.2 Which Exceptions Might a Method Throw?
    7. 13.5 finally Block
      1. 13.5.1 Moving Resource-Release Code to a finally Block
      2. 13.5.2 Demonstrating the finally Block
      3. 13.5.3 Throwing Exceptions Using the throw Statement
      4. 13.5.4 Rethrowing Exceptions
      5. 13.5.5 Returning After a finally Block
    8. 13.6 The using Statement
    9. 13.7 Exception Properties
      1. 13.7.1 Property InnerException
      2. 13.7.2 Other Exception Properties
      3. 13.7.3 Demonstrating Exception Properties and Stack Unwinding
      4. 13.7.4 Throwing an Exception with an InnerException
      5. 13.7.5 Displaying Information About the Exception
    10. 13.8 User-Defined Exception Classes
      1. Class NegativeNumberException
      2. Using Class NegativeNumberException
    11. 13.9 Checking for null References; Introducing C# 6’s References; Introducing C# 6’s ?. Operator
      1. 13.9.1 Null-Conditional Operator (?.)
      2. 13.9.2 Revisiting Operators is and as
      3. 13.9.3 Nullable Types
      4. 13.9.4 Null Coalescing Operator (??)
    12. 13.10 Exception Filters and the C# 6 when Clause
    13. 13.11 Wrap-Up
    14. Summary
      1. Section 13.1 Introduction
      2. Section 13.2 Example: Divide by Zero without Exception Handling
      3. Section 13.2.1 Dividing By Zero
      4. Section 13.2.2 Enter a Non-Numeric Denominator
      5. Section 13.3.1 Enclosing Code in a try Block
      6. Section 13.3.2 Catching Exceptions
      7. Section 13.3.3 Uncaught Exceptions
      8. Section 13.3.4 Termination Model of Exception Handling
      9. Section 13.3.5 Flow of Control When Exceptions Occur
      10. Section 13.4 .NET Exception Hierarchy
      11. Section 13.4.1 Class SystemException
      12. Section 13.5 finally Block
      13. Section 13.5.1 Moving Resource-Release Code to a finally Block
      14. Section 13.6 The using Statement
      15. Section 13.7 Exception Properties
      16. Section 13.7.1 Property InnerException
      17. Section 13.7.3 Demonstrating Exception Properties and Stack Unwinding
      18. Section 13.8 User-Defined Exception Classes
      19. Section 13.9.1 Null-Conditional Operator (?.)
      20. Section 13.9.3 Nullable Types
      21. Section 13.9.4 Null Coalescing Operator (??)
      22. Section 13.10 Exception Filters and the C# 6 when Clause
    15. Terminology
    16. Self-Review Exercises
    17. Exercises
  23. 14 Graphical User Interfaces with Windows Forms: Part 1
    1. Objectives
    2. Outline
    3. 14.1 Introduction
    4. 14.2 Windows Forms
    5. 14.3 Event Handling
      1. 14.3.1 A Simple Event-Driven GUI
        1. Renaming the Form1.cs File
        2. Adding a Button to the Form
        3. Adding an Event Handler for the Button’s ’s Click Event
        4. Event Handler Parameters
        5. Displaying a MessageBox
      2. 14.3.2 Auto-Generated GUI Code
      3. 14.3.3 Delegates and the Event-Handling Mechanism
        1. Delegates
        2. Indicating the Method that a Delegate Should Call
        3. (Optional) Multicast Delegates
      4. 14.3.4 Another Way to Create Event Handlers
        1. Using the Properties Window to Create Event Handlers
      5. 14.3.5 Locating Event Information
    6. 14.4 Control Properties and Layout
      1. 14.4.1 Anchoring and Docking
        1. Anchoring Demonstration
      2. 14.4.2 Using Visual Studio To Edit a GUI’s LayoutUsing Visual Studio To Edit a GUI’s Layout
    7. 14.5 Labels, TextBoxes and Buttons
    8. 14.6 GroupBoxes and Panels
    9. 14.7 CheckBoxes and RadioButtons
      1. 14.7.1 CheckBoxes
      2. 14.7.2 Combining Font Styles with Bitwise Operators
      3. 14.7.3 RadioButtons
    10. 14.8 PictureBoxes
      1. Using Resources Programmatically
    11. 14.9 ToolTips
    12. 14.10 NumericUpDown Control
    13. 14.11 Mouse-Event Handling
    14. 14.12 Keyboard-Event Handling
    15. 14.13 Wrap-Up
    16. Summary
      1. Section 14.1 Introduction
      2. Section 14.2 Windows Forms
      3. Section 14.3 Event Handling
      4. Section 14.3.1 A Simple Event-Driven GUI
      5. Section 14.3.2 Auto-Generated GUI Code
      6. Section 14.3.3 Delegates and the Event-Handling Mechanism
      7. Section 14.3.4 Another Way to Create Event Handlers
      8. Section 14.3.5 Locating Event Information
      9. Section 14.4 Control Properties and Layout
      10. Section 14.5 Labels, TextBoxes and Buttons
      11. Section 14.6 GroupBoxes and Panels
      12. Section 14.7 CheckBoxes and RadioButtons
      13. Section 14.8 PictureBoxes
      14. Section 14.9 ToolTips
      15. Section 14.10 NumericUpDown Control
      16. Section 14.11 Mouse-Event Handling
      17. Section 14.12 Keyboard-Event Handling
    17. Terminology
    18. Self-Review Exercises
    19. Exercises
    20. Making-a-Difference Exercises
  24. 15 Graphical User Interfaces with Windows Forms: Part 2
    1. Objectives
    2. Outline
    3. 15.1 Introduction
    4. 15.2 Menus
    5. 15.3 MonthCalendar Control
    6. 15.4 DateTimePicker Control
    7. 15.5 LinkLabel Control
    8. 15.6 ListBox Control
    9. 15.7 CheckedListBox Control
    10. 15.8 ComboBox Control
    11. 15.9 TreeView Control
    12. 15.10 ListView Control
    13. 15.11 TabControl Control
    14. 15.12 Multiple Document Interface (MDI) Windows
    15. 15.13 Visual Inheritance
    16. 15.14 User-Defined Controls
    17. 15.15 Wrap-Up
    18. Summary
      1. Section 15.2 Menus
      2. Section 15.3 MonthCalendar Control
      3. Section 15.4 DateTimePicker Control
      4. Section 15.5 LinkLabel Control
      5. Section 15.6 ListBox Control
      6. Section 15.7 CheckedListBox Control
      7. Section 15.8 ComboBox Control
      8. Section 15.9 TreeView Control
      9. Section 15.10 ListView Control
      10. Section 15.11 TabControl Control
      11. Section 15.12 Multiple Document Interface (MDI) Windows
      12. Section 15.13 Visual Inheritance
      13. Section 15.14 User-Defined Controls
    19. Terminology
    20. Self-Review Exercises
    21. Exercises
  25. 16 Strings and Characters: A Deeper Look
    1. Objectives
    2. Outline
    3. 16.1 Introduction
    4. 16.2 Fundamentals of Characters and Strings
    5. 16.3 string Constructors
    6. 16.4 string Indexer, Length Property and CopyTo Method
    7. 16.5 Comparing strings
    8. 16.6 Locating Characters and Substrings in strings
    9. 16.7 Extracting Substrings from strings
    10. 16.8 Concatenating strings
    11. 16.9 Miscellaneous string Methods
    12. 16.10 Class StringBuilder
    13. 16.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder
    14. 16.12 Append and AppendFormat Methods of Class StringBuilder
    15. 16.13 Insert, Remove and Replace Methods of Class StringBuilder
    16. 16.14 Char Methods
    17. 16.15 Introduction to Regular Expressions (Online)
    18. 16.16 Wrap-Up
    19. Summary
      1. Section 16.2 Fundamentals of Characters and Strings
      2. Section 16.3 string Constructors
      3. Section 16.4 string Indexer, Length Property and CopyTo Method
      4. Section 16.5 Comparing strings
      5. Section 16.6 Locating Characters and Substrings in strings
      6. Section 16.7 Extracting Substrings from strings
      7. Section 16.8 Concatenating strings
      8. Section 16.10 Class StringBuilder
      9. Section 16.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder
      10. Section 16.12 Append and AppendFormat Methods of Class StringBuilder
      11. Section 16.13 Insert, Remove and Replace Methods of Class StringBuilder
      12. Section 16.14 Char Methods
    20. Terminology
    21. Self-Review Exercises
    22. Exercises
    23. Making-a-Difference Exercises
  26. 17 Files and Streams
    1. Objectives
    2. Outline
    3. 17.1 Introduction
    4. 17.2 Files and Streams
    5. 17.3 Creating a Sequential-Access Text File
    6. 17.4 Reading Data from a Sequential-Access Text File
    7. 17.5 Case Study: Credit-Inquiry Program
    8. 17.6 Serialization
    9. 17.7 Creating a Sequential-Access File Using Object Serialization
    10. 17.8 Reading and Deserializing Data from a Binary File
    11. 17.9 Classes File and Directory
      1. 17.9.1 Demonstrating Classes File and Directory
      2. 17.9.2 Searching Directories with LINQ
        1. Method SearchDirectory
        2. Method CleanDirectory
    12. 17.10 Wrap-Up
    13. Summary
      1. Section 17.1 Introduction
      2. Section 17.2 Files and Streams
      3. Section 17.3 Creating a Sequential-Access Text File
      4. Section 17.4 Reading Data from a Sequential-Access Text File
      5. Section 17.5 Case Study: Credit-Inquiry Program
      6. Section 17.6 Serialization
      7. Section 17.7 Creating a Sequential-Access File Using Object Serialization
      8. Section 17.8 Reading and Deserializing Data from a Binary File
      9. Section 17.9 Classes File and Directory
    14. Terminology
    15. Self-Review Exercises
    16. Exercises
    17. Making-a-Difference Exercises
  27. 18 Searching and Sorting
    1. Objectives
    2. Outline
    3. 18.1 Introduction
    4. 18.2 Searching Algorithms
      1. 18.2.1 Linear Search
        1. Performing a Linear Search
        2. Method LinearSearch
        3. Efficiency of Linear Search
        4. Constant Runtime
        5. Linear Runtime
        6. Quadratic Runtime
        7. Linear Search Runtime
      2. 18.2.2 Binary Search
        1. Implementing Binary Search
        2. Method BinarySearch
        3. Efficiency of Binary Search
    5. 18.3 Sorting Algorithms
      1. 18.3.1 Selection Sort
        1. Implementing Selection Sort
        2. Method SelectionSort
        3. Efficiency of Selection Sort
      2. 18.3.2 Insertion Sort
        1. Implementing Insertion Sort
        2. Efficiency of Insertion Sort
      3. 18.3.3 Merge Sort
        1. Implementing Merge Sort
        2. Method SortArray
        3. Method Merge
        4. Efficiency of Merge Sort
    6. 18.4 Summary of the Efficiency of Searching and Sorting Algorithms
    7. 18.5 Wrap-Up
    8. Summary
      1. Section 18.1 Introduction
      2. Section 18.2.1 Linear Search
      3. Section 18.2.2 Binary Search
      4. Section 18.3.1 Selection Sort
      5. Section 18.3.2 Insertion Sort
      6. Section 18.3.3 Merge Sort
    9. Terminology
    10. Self-Review Exercises
    11. Exercises
  28. 19 Custom Linked Data Structures
    1. Objectives
    2. Outline
    3. 19.1 Introduction
    4. 19.2 Simple-Type structs, Boxing and Unboxing
    5. 19.3 Self-Referential Classes
    6. 19.4 Linked Lists
    7. 19.5 Stacks
    8. 19.6 Queues
    9. 19.7 Trees
      1. 19.7.1 Binary Search Tree of Integer Values
        1. Inorder Traversal Algorithm
        2. Preorder Traversal Algorithm
        3. Postorder Traversal Algorithm
        4. Duplicate Elimination
        5. Overview of the Level-Order Binary-Tree Exercise
      2. 19.7.2 Binary Search Tree of IComparable Objects
    10. 19.8 Wrap-Up
    11. Summary
      1. Section 19.1 Introduction
      2. Section 19.2 Simple-Type structs, Boxing and Unboxing
      3. Section 19.3 Self-Referential Classes
      4. Section 19.4 Linked Lists
      5. Section 19.5 Stacks
      6. Section 19.6 Queues
      7. Section 19.7 Trees
    12. Terminology
    13. Self-Review Exercises
    14. Exercises
    15. Special Section: Building Your Own Compiler
  29. 20 Generics
    1. Objectives
    2. Outline
    3. 20.1 Introduction
    4. 20.2 Motivation for Generic Methods
    5. 20.3 Generic-Method Implementation
    6. 20.4 Type Constraints
      1. 20.4.1 IComparable&lt;T&gt; InterfaceIComparable<T> Interface
      2. 20.4.2 Specifying Type Constraints
        1. Specifying the Type Constraint with a where Clause
        2. Kinds of Type Constraints
        3. Applying Multiple Type Constraints
        4. Analyzing the Code
        5. Value Types vs. Reference Types in Generics
    7. 20.5 Overloading Generic Methods
    8. 20.6 Generic Classes
    9. 20.7 Wrap-Up
    10. Summary
      1. Section 20.1 Introduction
      2. Section 20.2 Motivation for Generic Methods
      3. Section 20.3 Generic-Method Implementation
      4. Section 20.4 Type Constraints
      5. Section 20.5 Overloading Generic Methods
      6. Section 20.6 Generic Classes
    11. Terminology
    12. Self-Review Exercises
    13. Exercises
  30. 21 Generic Collections; Functional Programming with LINQ/PLINQ
    1. Objectives
    2. Outline
    3. 21.1 Introduction
    4. 21.2 Collections Overview
    5. 21.3 Class Array and Enumerators
      1. 21.3.1 C# 6 using static Directive
      2. 21.3.2 Class UsingArray&#8217;s ’s static Fields
      3. 21.3.3 Array Method Sort
      4. 21.3.4 Array Method Copy
      5. 21.3.5 Array Method BinarySearch
      6. 21.3.6 Array Method GetEnumerator and Interface IEnumerator
      7. 21.3.7 Iterating Over a Collection with foreach
      8. 21.3.8 Array Methods Clear, IndexOf, LastIndexOf and Reverse
    6. 21.4 Dictionary Collections
      1. 21.4.1 Dictionary Fundamentals
        1. Hashing
        2. Collisions
        3. Load Factor
        4. Hash Function
      2. 21.4.2 Using the SortedDictionary Collection
        1. Method CollectWords
        2. SortedDictionary Methods ContainsKey and Add
        3. SortedDictionary Indexer
        4. Method DisplayDictionary
        5. Iterating Over a SortedDictionary&#8217;s ’s KeyValuePairs
        6. SortedDictionary&#8217;s ’s Values Property
    7. 21.5 Generic LinkedList Collection
    8. 21.6 C# 6 Null Conditional Operator ?[]
    9. 21.7 C# 6 Dictionary Initializers and Collection Initializers
    10. 21.8 Delegates
      1. 21.8.1 Declaring a Delegate Type
      2. 21.8.2 Declaring a Delegate Variable
      3. 21.8.3 Delegate Parameters
      4. 21.8.4 Passing a Method Name Directly to a Delegate Parameter
    11. 21.9 Lambda Expressions
      1. 21.9.1 Expression Lambdas
      2. 21.9.2 Assigning Lambdas to Delegate Variables
      3. 21.9.3 Explicitly Typed Lambda Parameters
      4. 21.9.4 Statement Lambdas
    12. 21.10 Introduction to Functional Programming
    13. 21.11 Functional Programming with LINQ Method-Call Syntax and Lambdas
      1. 21.11.1 LINQ Extension Methods Min, Max, Sum and Average
        1. Iteration and Mutation Are Hidden from You
      2. 21.11.2 Aggregate Extension Method for Reduction Operations
        1. Summing the Squares of the Values with Method Aggregate
        2. Calculating the Product of the Values with Method Aggregate
      3. 21.11.3 The Where Extension Method for Filtering Operations
        1. Sorting the Results
        2. Deferred Execution
      4. 21.11.4 Select Extension Method for Mapping Operations
    14. 21.12 PLINQ: Improving LINQ to Objects Performance with Multicore
    15. 21.13 (Optional) Covariance and Contravariance for Generic Types
    16. 21.14 Wrap-Up
    17. Summary
      1. Section 21.1 Introduction
      2. Section 21.2 Collections Overview
      3. Section 21.3 Class Array and Enumerators
      4. Section 21.3.1 C# 6 using static Directive
      5. Section 21.3.3 Array Method Sort
      6. Section 21.3.4 Array Method Copy
      7. Section 21.3.5 Array Method BinarySearch
      8. Section 21.3.6 Array Method GetEnumerator and Interface IEnumerator
      9. Section 21.3.7 Iterating Over a Collection with foreach
      10. Section 21.3.8 Array Methods Clear, IndexOf, LastIndexOf and Reverse
      11. Section 21.4 Dictionary Collections
      12. Section 21.4.1 Dictionary Fundamentals
      13. Section 21.4.2 Using the SortedDictionary Collection
      14. Section 21.5 Generic LinkedList Collection
      15. Section 21.6 C# 6 Null Conditional Operator ?[]
      16. Section 21.7 C# 6 Dictionary Initializers and Collection Initializers
      17. Section 21.8 Delegates
      18. Section 21.8.1 Declaring a Delegate Type
      19. Section 21.8.2 Declaring a Delegate Variable
      20. Section 21.8.3 Delegate Parameters
      21. Section 21.8.4 Passing a Method Name Directly to a Delegate Parameter
      22. Section 21.9 Lambda Expressions
      23. Section 21.9.1 Expression Lambdas
      24. Section 21.9.2 Assigning Lambdas to Delegate Variables
      25. Section 21.9.3 Explicitly Typed Lambda Parameters
      26. Section 21.9.4 Statement Lambdas
      27. Section 21.10 Introduction to Functional Programming
      28. Section 21.11 Functional Programming with LINQ Method-Call Syntax and Lambdas
      29. Section 21.11.1 LINQ Extension Methods Min, Max, Sum and Average
      30. Section 21.11.2 Aggregate Extension Method for Reduction Operations
      31. Section 21.11.3 The Where Extension Method for Filtering Operations
      32. Section 21.11.4 Select Extension Method for Mapping Operations
      33. Section 21.12 PLINQ: Improving LINQ to Objects Performance with Multicore
      34. Section 21.13 (Optional) Covariance and Contravariance for Generic Types
    18. Terminology
    19. Self-Review Exercises
    20. Exercises
      1. Functional-Programming Exercises
  31. 22 Databases and LINQ
    1. Objectives
    2. Outline
    3. 22.1 Introduction
    4. 22.2 Relational Databases
    5. 22.3 A Books Database
    6. 22.4 LINQ to Entities and the ADO.NET Entity Framework
    7. 22.5 Querying a Database with LINQ
      1. 22.5.1 Creating the ADO.NET Entity Data Model Class Library
        1. Step 1: Creating a Class Library Project for the ADO.NET Entity Data Model
        2. Step 2: Adding the ADO.NET Entity Data Model to the Class Library
      2. 22.5.2 Creating a Windows Forms Project and Configuring It to Use the Entity Data Model
        1. Step 1: Creating the Project
        2. Step 2: Adding a Reference to the BooksExamples Class Library
        3. Step 3: Adding a Reference to EntityFramework
        4. Step 4: Adding the Connection String to the Windows Forms App
      3. 22.5.3 Data Bindings Between Controls and the Entity Data Model
        1. Step 1: Adding a Data Source for the Authors Table
        2. Step 2: Creating GUI Elements
        3. Step 3: Connecting the Data Source to the authorBindingSource
        4. Creating the DbContext Object
        5. DisplayAuthorsTable_Load Event Handler
        6. authorBindingNavigatorSaveItem_Click Event Handler: Saving Modifications to the Database
    8. 22.6 Dynamically Binding Query Results
      1. 22.6.1 Creating the Display Query Results GUI
        1. Step 1: Creating the Project
        2. Step 2: Creating a DataGridView to Display the Titles Table
        3. Step 3: Adding a ComboBox to the Form
      2. 22.6.2 Coding the Display Query Results App
        1. Customizing the Form&#8217;s ’s Load Event Handler
        2. queriesComboBox_SelectedIndexChanged Event Handler
        3. Ordering the Books By Title
        4. Selecting Books with 2016 Copyright
        5. Selecting Books with Titles That End in “How to Program”
    9. 22.7 Retrieving Data from Multiple Tables with LINQ
    10. 22.8 Creating a Master/Detail View App
      1. 22.8.1 Creating the Master/Detail GUI
        1. Step 1: Creating the Project
        2. Step 2: Adding a Data Source for the Authors Table
        3. Step 3: Creating GUI Elements
      2. 22.8.2 Coding the Master/Detail App
    11. 22.9 Address Book Case Study
      1. 22.9.1 Creating the Address Book App&#8217;s GUI Creating the Address Book App’s GUI
        1. Step 1: Creating a Class Library Project for the Entity Data Model
        2. Step 2: Creating a Windows Forms Application Project for the AddressBook App
        3. Step 3: Adding the Address Object as a Data Source
        4. Step 4: Displaying the Details of Each Row
        5. Step 5: Dragging the Address Data-Source Node to the Form
        6. Step 5: Making the AddressID TextBox ReadOnly
        7. Step 6: Adding Controls to Allow Users to Specify a Last Name to Locate
        8. Step 7: Allowing the User to Return to Browsing All Rows of the Database
      2. 22.9.2 Coding the Address Book App
        1. Method RefreshContacts
        2. Method Contacts_Load
        3. Method addressBindingNavigatorSaveItem_Click
        4. Method findButton_Click
        5. Method browseAllButton_Click
    12. 22.10 Tools and Web Resources
    13. 22.11 Wrap-Up
    14. Summary
      1. Section 22.1 Introduction
      2. Section 22.2 Relational Databases
      3. Section 22.3 A Books Database
      4. Section 22.4 LINQ to Entities and the ADO.NET Entity Framework
      5. Section 22.5 Querying a Database with LINQ
      6. Section 22.5.1 Creating the ADO.NET Entity Data Model Class Library
      7. Section 22.5.2 Creating a Windows Forms Project and Configuring It to Use the Entity Data Model
      8. Section 22.5.3 Data Bindings Between Controls and the Entity Data Model
      9. Section 22.6 Dynamically Binding Query Results
      10. Section 22.7 Retrieving Data from Multiple Tables with LINQ
      11. Section 22.8 Creating a Master/Detail View App
      12. Section 22.9 Address Book Case Study
    15. Terminology
    16. Self-Review Exercises
    17. Exercises
  32. 23 Asynchronous Programming with async and await
    1. Objectives
    2. Outline
    3. 23.1 Introduction
    4. 23.2 Basics of async and await
      1. 23.2.1 async Modifier
      2. 23.2.2 await Expression
      3. 23.2.3 async, await and Threads
    5. 23.3 Executing an Asynchronous Task from a GUI App
      1. 23.3.1 Performing a Task Asynchronously
        1. A Compute-Intensive Algorithm: Calculating Fibonacci Numbers Recursively
        2. Exponential Complexity
      2. 23.3.2 Method calculateButton_Click
      3. 23.3.3 Task Method Run: Executing Asynchronously in a Separate Thread
      4. 23.3.4 awaiting the Result
      5. 23.3.5 Calculating the Next Fibonacci Value Synchronously
    6. 23.4 Sequential Execution of Two Compute-Intensive Tasks
    7. 23.5 Asynchronous Execution of Two Compute-Intensive Tasks
      1. 23.5.1 awaiting Multiple Tasks with Task Method WhenAll
      2. 23.5.2 Method StartFibonacci
      3. 23.5.3 Modifying a GUI from a Separate Thread
      4. 23.5.4 awaiting One of Several Tasks with Task Method WhenAny
    8. 23.6 Invoking a Flickr Web Service Asynchronously with HttpClient
      1. 23.6.1 Using Class HttpClient to Invoke a Web Service
      2. 23.6.2 Invoking the Flickr Web Service&#8217;s Invoking the Flickr Web Service’s flickr.photos.search Method
      3. 23.6.3 Processing the XML Response
        1. XML Elements and Attributes
        2. Class XDocument and LINQ to XML
      4. 23.6.4 Binding the Photo Titles to the ListBox
      5. 23.6.5 Asynchronously Downloading an Image&#8217;s BytesAsynchronously Downloading an Image’s Bytes
    9. 23.7 Displaying an Asynchronous Task&#8217;s ProgressDisplaying an Asynchronous Task’s Progress
    10. 23.8 Wrap-Up
    11. Summary
      1. Section 23.1 Introduction
      2. Section 23.2.1 async Modifier
      3. Section 23.2.2 await Expression
      4. Section 23.2.3 async, await and Threads
      5. Section 23.3.1 Performing a Task Asynchronously
      6. Section 23.3.2 Method calculateButton_Click
      7. Section 23.3.3 Task Method Run: Executing Asynchronously in a Separate Thread
      8. Section 23.3.4 awaiting the Result
      9. Section 23.3.5 Calculating the Next Fibonacci Value Synchronously
      10. Section 23.4 Sequential Execution of Two Compute-Intensive Tasks
      11. Section 23.5 Asynchronous Execution of Two Compute-Intensive Tasks
      12. Section 23.5.1 awaiting Multiple Tasks with Task Method WhenAll
      13. Section 23.5.3 Modifying a GUI from a Separate Thread
      14. Section 23.5.4 awaiting One of Several Tasks with Task Method WhenAny
      15. Section 23.6 Invoking a Flickr Web Service Asynchronously with HttpClient
      16. Section 23.6.1 Using Class HttpClient to Invoke a Web Service
      17. Section 23.6.2 Invoking the Flickr Web Service&#8217;s Invoking the Flickr Web Service’s flickr.photos.search Method
      18. Section 23.6.3 Processing the XML Response
      19. Section 23.6.4 Binding the Photo Titles to the ListBox
      20. Section 23.6.5 Asynchronously Downloading an Image&#8217;s Bytes Asynchronously Downloading an Image’s Bytes
      21. Section 23.7 Displaying an Asynchronous Task&#8217;s Progress Displaying an Asynchronous Task’s Progress
    12. Terminology
    13. Self-Review Exercises
    14. Exercises
  33. Chapters on the Web
  34. A Operator Precedence Chart
  35. B Simple Types
  36. C ASCII Character Set
  37. Appendices on the Web
  38. Index
    1. Symbols
    2. Numerics
    3. A
    4. B
    5. C
    6. D
    7. E
    8. F
    9. G
    10. H
    11. I
    12. J
    13. K
    14. L
    15. M
    16. N
    17. O
    18. P
    19. Q
    20. R
    21. S
    22. T
    23. U
    24. V
    25. W
    26. X
    27. Y
    28. Z