Book description
The professional programmer’s Deitel® guide to C# 6 and object-oriented development for Windows®
Written for programmers with a background in high-level language programming, C# 6 for Programmers applies the Deitel signature live-code approach to teaching programming and explores Microsoft’s C# 6 and .NET in depth. Concepts are presented in the context of 170+ fully coded and tested apps, complete with syntax shading, code highlighting, code walkthroughs, program outputs and hundreds of savvy software-development tips.
Start with an introduction to C# using an early classes and objects approach, then rapidly move on to more advanced topics, including LINQ, asynchronous programming with async and await and more. You’ll enjoy the treatment of object-oriented programming and an object-oriented design/UML® ATM case study, including a complete C# implementation. When you’ve mastered the book, you’ll be ready to start building industrial-strength, object-oriented C# apps.
Paul Deitel and Harvey Deitel are the founders of Deitel & Associates, Inc., the internationally recognized programming languages authoring and corporate training organization. Millions of people worldwide have used Deitel textbooks, professional books, LiveLessons™ video products, e-books, resource centers and REVEL™ interactive multimedia courses with integrated labs and assessment to master major programming languages and platforms, including C#, C++, C, Java™, Android™ app development, iOS app development, Swift™, Visual Basic®, Python™ and Internet and web programming.
Features:
Use with Windows® 7, 8 or 10.
Integrated coverage of new C# 6 functionality: string interpolation, expression-bodied methods and properties, auto-implemented property initializers, getter-only properties, nameof, null-conditional operator, exception filters and more.
Entertaining and challenging code examples.
Deep treatment of classes, objects, inheritance, polymorphism and interfaces.
Generics, LINQ and generic collections; PLINQ (Parallel LINQ) for multicore performance.
Asynchronous programming with async and await; functional programming with lambdas, delegates and immutability.
Files; relational database with LINQ to Entities.
Object-oriented design ATM case study with full code implementation.
Emphasis on performance and software engineering principles.
Visit www.deitel.com
Download code examples
For Deitel’s programming training courses, www.deitel.com/training or write to deitel@deitel.com
Join the Deitel social networking communities:
Facebook® at facebook.com/DeitelFan
Twitter® at twitter.com/deitel
LinkedIn® at bit.ly/DeitelLinkedIn
YouTube™ at youtube.com/DeitelTV
Google+™ at google.com/+DeitelFan
Subscribe to the Deitel® Buzz e-mail newsletter at www.deitel.com/newsletter/subscribe.html
Table of contents
- About This E-Book
- Title Page
- Copyright Page
- Deitel® Series Page
- Dedication
- Contents
-
Preface
- Contacting the Authors
- Join the Deitel & Associates, Inc. Social Media Communities
- New C# 6 Features
-
A Tour of the Book
- Introduction to Visual C# and Visual Studio 2015 Community Edition
- Introduction to C# Fundamentals
- Object-Oriented Programming: A Deeper Look
- Windows Forms Graphical User Interfaces (GUIs)
- Strings and Files
- Generics and Generic Collections
- Functional Programming with LINQ, PLINQ, Lambdas, Delegates and Immutability
- Database with LINQ to Entities and SQL Server
- Asynchronous Programming
- Online Bonus Content
- Future Online Bonus Content
- Notes About the Presentation
- Obtaining the Software Used in C# 6 for Programmers, 6/e
- Microsoft DreamSpark™
- Acknowledgments
- Reviewers
- About the Authors
- About Deitel & Associates, Inc.
- Before You Begin
- 1. Introduction
- 2. Introduction to Visual Studio and Visual Programming
-
3. Introduction to C# App Programming
- 3.1 Introduction
- 3.2 Simple App: Displaying a Line of Text
- 3.3 Creating a Simple App in Visual Studio
- 3.4 Modifying Your Simple C# App
- 3.5 String Interpolation
-
3.6 Another C# App: Adding Integers
- 3.6.1 Declaring the int Variable number1
- 3.6.2 Declaring Variables number2 and sum
- 3.6.3 Prompting the User for Input
- 3.6.4 Reading a Value into Variable number1
- 3.6.5 Prompting the User for Input and Reading a Value into number2
- 3.6.6 Summing number1 and number2
- 3.6.7 Displaying the sum with string Interpolation
- 3.6.8 Performing Calculations in Output Statements
- 3.7 Arithmetic
- 3.8 Decision Making: Equality and Relational Operators
- 3.9 Wrap-Up
-
4. Introduction to Classes, Objects, Methods and strings
- 4.1 Introduction
- 4.2 Test-Driving an Account Class
- 4.3 Account Class with an Instance Variable and Set and Get Methods
- 4.4 Creating, Compiling and Running a Visual C# Project with Two Classes
- 4.5 Software Engineering with Set and Get Methods
- 4.6 Account Class with a Property Rather Than Set and Get Methods
- 4.7 Auto-Implemented Properties
- 4.8 Account Class: Initializing Objects with Constructors
- 4.9 Account Class with a Balance; Processing Monetary Amounts
- 4.10 Wrap-Up
-
5. Control Statements: Part 1
- 5.1 Introduction
- 5.2 Control Structures
- 5.3 if Single-Selection Statement
- 5.4 if...else Double-Selection Statement
- 5.5 Student Class: Nested if...else Statements
- 5.6 while Iteration Statement
- 5.7 Counter-Controlled Iteration
- 5.8 Sentinel-Controlled Iteration
- 5.9 Nested Control Statements
- 5.10 Compound Assignment Operators
- 5.11 Increment and Decrement Operators
- 5.12 Simple Types
- 5.13 Wrap-Up
-
6. Control Statements: Part 2
- 6.1 Introduction
- 6.2 Essentials of Counter-Controlled Iteration
- 6.3 for Iteration Statement
- 6.4 App: Summing Even Integers
- 6.5 App: Compound-Interest Calculations
- 6.6 do...while Iteration Statement
- 6.7 switch Multiple-Selection Statement
- 6.8 Class AutoPolicy Case Study: strings in switch Statements
- 6.9 break and continue Statements
-
6.10 Logical Operators
- 6.10.1 Conditional AND (&&) Operator
- 6.10.2 Conditional OR (||) Operator
- 6.10.3 Short-Circuit Evaluation of Complex Conditions
- 6.10.4 Boolean Logical AND (&) and Boolean Logical OR (|) Operators
- 6.10.5 Boolean Logical Exclusive OR (^)
- 6.10.6 Logical Negation (!) Operator
- 6.10.7 Logical Operators Example
- 6.11 Wrap-Up
-
7. Methods: A Deeper Look
- 7.1 Introduction
- 7.2 Packaging Code in C#
- 7.3 static Methods, static Variables and Class Math
- 7.4 Methods with Multiple Parameters
- 7.5 Notes on Using Methods
- 7.6 Argument Promotion and Casting
- 7.7 The .NET Framework Class Library
-
7.8 Case Study: Random-Number Generation
- 7.8.1 Creating an Object of Type Random
- 7.8.2 Generating a Random Integer
- 7.8.3 Scaling the Random-Number Range
- 7.8.4 Shifting Random-Number Range
- 7.8.5 Combining Shifting and Scaling
- 7.8.6 Rolling a Six-Sided Die
- 7.8.7 Scaling and Shifting Random Numbers
- 7.8.8 Repeatability for Testing and Debugging
- 7.9 Case Study: A Game of Chance; Introducing Enumerations
- 7.10 Scope of Declarations
- 7.11 Method-Call Stack and Activation Records
- 7.12 Method Overloading
- 7.13 Optional Parameters
- 7.14 Named Parameters
- 7.15 C# 6 Expression-Bodied Methods and Properties
- 7.16 Recursion
- 7.17 Value Types vs. Reference Types
- 7.18 Passing Arguments By Value and By Reference
- 7.19 Wrap-Up
-
8. Arrays; Introduction to Exception Handling
- 8.1 Introduction
- 8.2 Arrays
- 8.3 Declaring and Creating Arrays
-
8.4 Examples Using Arrays
- 8.4.1 Creating and Initializing an Array
- 8.4.2 Using an Array Initializer
- 8.4.3 Calculating a Value to Store in Each Array Element
- 8.4.4 Summing the Elements of an Array
- 8.4.5 Iterating Through Arrays with foreach
- 8.4.6 Using Bar Charts to Display Array Data Graphically; Introducing Type Inference with var
- 8.4.7 Using the Elements of an Array as Counters
- 8.5 Using Arrays to Analyze Survey Results; Intro to Exception Handling
- 8.6 Case Study: Card Shuffling and Dealing Simulation
- 8.7 Passing Arrays and Array Elements to Methods
- 8.8 Case Study: GradeBook Using an Array to Store Grades
- 8.9 Multidimensional Arrays
- 8.10 Case Study: GradeBook Using a Rectangular Array
- 8.11 Variable-Length Argument Lists
- 8.12 Using Command-Line Arguments
- 8.13 (Optional) Passing Arrays by Value and by Reference
- 8.14 Wrap-Up
- 9. Introduction to LINQ and the List Collection
-
10. Classes and Objects: A Deeper Look
- 10.1 Introduction
- 10.2 Time Class Case Study; Throwing Exceptions
- 10.3 Controlling Access to Members
- 10.4 Referring to the Current Object’s Members with the this Reference
- 10.5 Time Class Case Study: Overloaded Constructors
- 10.6 Default and Parameterless Constructors
- 10.7 Composition
- 10.8 Garbage Collection and Destructors
- 10.9 static Class Members
- 10.10 readonly Instance Variables
- 10.11 Class View and Object Browser
- 10.12 Object Initializers
- 10.13 Operator Overloading; Introducing struct
- 10.14 Time Class Case Study: Extension Methods
- 10.15 Wrap-Up
-
11. Object-Oriented Programming: Inheritance
- 11.1 Introduction
- 11.2 Base Classes and Derived Classes
- 11.3 protected Members
-
11.4 Relationship between Base Classes and Derived Classes
- 11.4.1 Creating and Using a CommissionEmployee Class
- 11.4.2 Creating a BasePlusCommissionEmployee Class without Using Inheritance
- 11.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
- 11.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
- 11.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
- 11.5 Constructors in Derived Classes
- 11.6 Software Engineering with Inheritance
- 11.7 Class object
- 11.8 Wrap-Up
-
12. OOP: Polymorphism and Interfaces
- 12.1 Introduction
- 12.2 Polymorphism Examples
- 12.3 Demonstrating Polymorphic Behavior
- 12.4 Abstract Classes and Methods
-
12.5 Case Study: Payroll System Using Polymorphism
- 12.5.1 Creating Abstract Base Class Employee
- 12.5.2 Creating Concrete Derived Class SalariedEmployee
- 12.5.3 Creating Concrete Derived Class HourlyEmployee
- 12.5.4 Creating Concrete Derived Class CommissionEmployee
- 12.5.5 Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
- 12.5.6 Polymorphic Processing, Operator is and Downcasting
- 12.5.7 Summary of the Allowed Assignments Between Base-Class and Derived-Class Variables
- 12.6 sealed Methods and Classes
-
12.7 Case Study: Creating and Using Interfaces
- 12.7.1 Developing an IPayable Hierarchy
- 12.7.2 Declaring Interface IPayable
- 12.7.3 Creating Class Invoice
- 12.7.4 Modifying Class Employee to Implement Interface IPayable
- 12.7.5 Using Interface IPayable to Process Invoices and Employees Polymorphically
- 12.7.6 Common Interfaces of the .NET Framework Class Library
- 12.8 Wrap-Up
-
13. Exception Handling: A Deeper Look
- 13.1 Introduction
- 13.2 Example: Divide by Zero without Exception Handling
- 13.3 Example: Handling DivideByZeroExceptions and FormatExceptions
- 13.4 .NET Exception Hierarchy
- 13.5 finally Block
- 13.6 The using Statement
- 13.7 Exception Properties
- 13.8 User-Defined Exception Classes
- 13.9 Checking for null References; Introducing C# 6’s ?. Operator
- 13.10 Exception Filters and the C# 6 when Clause
- 13.11 Wrap-Up
-
14. Graphical User Interfaces with Windows Forms: Part 1
- 14.1 Introduction
- 14.2 Windows Forms
- 14.3 Event Handling
- 14.4 Control Properties and Layout
- 14.5 Labels, TextBoxes and Buttons
- 14.6 GroupBoxes and Panels
- 14.7 CheckBoxes and RadioButtons
- 14.8 PictureBoxes
- 14.9 ToolTips
- 14.10 NumericUpDown Control
- 14.11 Mouse-Event Handling
- 14.12 Keyboard-Event Handling
- 14.13 Wrap-Up
-
15. Graphical User Interfaces with Windows Forms: Part 2
- 15.1 Introduction
- 15.2 Menus
- 15.3 MonthCalendar Control
- 15.4 DateTimePicker Control
- 15.5 LinkLabel Control
- 15.6 ListBox Control
- 15.7 CheckedListBox Control
- 15.8 ComboBox Control
- 15.9 TreeView Control
- 15.10 ListView Control
- 15.11 TabControl Control
- 15.12 Multiple Document Interface (MDI) Windows
- 15.13 Visual Inheritance
- 15.14 User-Defined Controls
- 15.15 Wrap-Up
-
16. Strings and Characters: A Deeper Look
- 16.1 Introduction
- 16.2 Fundamentals of Characters and Strings
- 16.3 string Constructors
- 16.4 string Indexer, Length Property and CopyTo Method
- 16.5 Comparing strings
- 16.6 Locating Characters and Substrings in strings
- 16.7 Extracting Substrings from strings
- 16.8 Concatenating strings
- 16.9 Miscellaneous string Methods
- 16.10 Class StringBuilder
- 16.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder
- 16.12 Append and AppendFormat Methods of Class StringBuilder
- 16.13 Insert, Remove and Replace Methods of Class StringBuilder
- 16.14 Char Methods
- 16.15 Introduction to Regular Expressions (Online)
- 16.16 Wrap-Up
-
17. Files and Streams
- 17.1 Introduction
- 17.2 Files and Streams
- 17.3 Creating a Sequential-Access Text File
- 17.4 Reading Data from a Sequential-Access Text File
- 17.5 Case Study: Credit-Inquiry Program
- 17.6 Serialization
- 17.7 Creating a Sequential-Access File Using Object Serialization
- 17.8 Reading and Deserializing Data from a Binary File
- 17.9 Classes File and Directory
- 17.10 Wrap-Up
- 18. Generics
-
19. Generic Collections; Functional Programming with LINQ/PLINQ
- 19.1 Introduction
- 19.2 Collections Overview
-
19.3 Class Array and Enumerators
- 19.3.1 C# 6 using static Directive
- 19.3.2 Class UsingArray’s static Fields
- 19.3.3 Array Method Sort
- 19.3.4 Array Method Copy
- 19.3.5 Array Method BinarySearch
- 19.3.6 Array Method GetEnumerator and Interface IEnumerator
- 19.3.7 Iterating Over a Collection with foreach
- 19.3.8 Array Methods Clear, IndexOf, LastIndexOf and Reverse
- 19.4 Dictionary Collections
- 19.5 Generic LinkedList Collection
- 19.6 C# 6 Null Conditional Operator ?[]
- 19.7 C# 6 Dictionary Initializers and Collection Initializers
- 19.8 Delegates
- 19.9 Lambda Expressions
- 19.10 Introduction to Functional Programming
- 19.11 Functional Programming with LINQ Method-Call Syntax and Lambdas
- 19.12 PLINQ: Improving LINQ to Objects Performance with Multicore
- 19.13 (Optional) Covariance and Contravariance for Generic Types
- 19.14 Wrap-Up
-
20. Databases and LINQ
- 20.1 Introduction
- 20.2 Relational Databases
- 20.3 A Books Database
- 20.4 LINQ to Entities and the ADO.NET Entity Framework
- 20.5 Querying a Database with LINQ
- 20.6 Dynamically Binding Query Results
- 20.7 Retrieving Data from Multiple Tables with LINQ
- 20.8 Creating a Master/Detail View App
- 20.9 Address Book Case Study
- 20.10 Tools and Web Resources
- 20.11 Wrap-Up
-
21. Asynchronous Programming with async and await
- 21.1 Introduction
- 21.2 Basics of async and await
- 21.3 Executing an Asynchronous Task from a GUI App
- 21.4 Sequential Execution of Two Compute-Intensive Tasks
- 21.5 Asynchronous Execution of Two Compute-Intensive Tasks
- 21.6 Invoking a Flickr Web Service Asynchronously with HttpClient
- 21.7 Displaying an Asynchronous Task’s Progress
- 21.8 Wrap-Up
-
22. XML and LINQ to XML
- 22.1 Introduction
- 22.2 XML Basics
- 22.3 Structuring Data
- 22.4 XML Namespaces
- 22.5 Document Type Definitions (DTDs)
-
22.6 W3C XML Schema Documents
- Validating Against an XML Schema Document
- Creating an XML Schema Document
- Defining an Element in XML Schema
- A Closer Look at Types in XML Schema
- XML Schema with Simple and Complext Types
- Opening schema Tag
- simpleType Element gigahertz
- complexType Element CPU
- complexType Element portable
- Using the laptop Element
- Automatically Creating Schemas using Visual Studio
- 22.7 Extensible Stylesheet Language and XSL Transformations
- 22.8 LINQ to XML: Document Object Model (DOM)
- 22.9 LINQ to XML Class Hierarchy
- 22.10 LINQ to XML: Namespaces and Creating Documents
- 22.11 XSLT with Class XslCompiledTransform
- 22.12 Wrap-Up
-
23. GUI with Windows Presentation Foundation
- 23.1 Introduction
- 23.2 Windows Presentation Foundation (WPF)
- 23.3 Declarative GUI Programming Using XAML
- 23.4 Creating a WPF App
- 23.5 Laying Out Controls
- 23.6 Event Handling
- 23.7 Commands and Common Application Tasks
- 23.8 WPF GUI Customization
- 23.9 Using Styles to Change the Appearance of Controls
- 23.10 Customizing Windows
- 23.11 Defining a Control’s Appearance with Control Templates
- 23.12 Data-Driven GUIs with Data Binding
- 23.13 Wrap-Up
- 24. WPF Graphics and Multimedia
- 25. ATM Case Study, Part 1: Object-Oriented Design with the UML
- 26. ATM Case Study, Part 2: Implementing an OO Design in C#
- A. Operator Precedence Chart
- B. Simple Types
- C. ASCII Character Set
-
D. Number Systems
- D.1 Introduction
- D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
- D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
- D.4 Converting from Binary, Octal or Hexadecimal to Decimal
- D.5 Converting from Decimal to Binary, Octal or Hexadecimal
- D.6 Negative Binary Numbers: Two’s Complement Notation
- E. UML 2: Additional Diagram Types
- F. Unicode®
- G. Using the Visual Studio Debugger
- Index
- Code Snippets
Product information
- Title: C# 6 for Programmers, Sixth Edition
- Author(s):
- Release date: August 2016
- Publisher(s): Pearson
- ISBN: 9780134596396
You might also like
book
Code Complete, 2nd Edition
Widely considered one of the best practical guides to programming, Steve McConnell’s original CODE COMPLETE has …
book
C# 10 in a Nutshell
When you have questions about C# 10 or .NET 6, this best-selling guide has the answers …
book
C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition
An accessible guide for beginner-to-intermediate programmers to the concepts, real-world applications, and latest features of C# …
book
C++20 for Programmers: An Objects-Natural Approach, 3rd Edition
The professional programmer's Deitel® guide to C++20 "C++20 for Programmers builds up an intuition for modern …