C# 2012 for Programmers

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

The professional programmer's Deitel(R) guide to C# 2012 and object-oriented development for Windows(R) 7 and Windows(R) 8 Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching programming and explores Microsoft's C# 2012 and .NET 4.5 in depth. The book presents the concepts in the context of fully tested apps, complete with syntax shading, code highlighting, code walkthroughs and program outputs. You'll work through 200+ complete C# apps with 15,000+ lines of proven C# code 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, Windows(R) 8 UI and WPF graphics and multimedia, web services, Windows(R) Phone 8, Windows Azure(TM) and more. You'll enjoy the treatment of object-oriented programming and an OOD/UML(R) ATM case study, including a complete C# implementation. When you're finished, you'll have everything you need to build 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 books, LiveLessons video training and online resource centers to master C#, .NET, Visual Basic(R), C++, Visual C++(R), C, Java(TM), Android(TM) app development, iOS(R) app development, Internet and web programming, JavaScript(R), XML, Perl(R), Python and more. Practical, example-rich coverage of: - .NET, Types, Arrays, Exception Handling- LINQ, Object/Collection Initializers- Objects, Classes, Inheritance, Polymorphism- Industrial-Strength, C#-Based Object-Oriented Design/UML(R) ATM Case Study- WinForms, WPF, Windows(R) 8 UI, XAML, Event Handling, Visual C# Debugging- WPF and Windows(R) 8 Graphics and Multimedia- Windows(R) Phone 8, Cloud Computing with Windows Azure(TM), Asynchronous Programming with async and await - Generic Collections, Methods and Classes- XML, LINQ to XML and LINQ to Entities- ASP.NET and ASP.NET Ajax- Web Forms, Web Controls- WCF REST-Based Web Services and more. Visit www.deitel.com
For information on Deitel's Dive Into(R) Series programming training courses delivered at organizations worldwide visit www.deitel.com/training or write to [email protected]
Download code examples
Join the Deitel social networking communities on Facebook(R) at facebook.com/DeitelFan, Twitter(R) @deitel, Google+(TM) at gplus.to/deitel and LinkedIn(R) at bit.ly/DeitelLinkedIn.
To receive updates for this book, subscribe to the Deitel(R) Buzz Online e-mail newsletter at www.deitel.com/newsletter/ subscribe.html

Author(s): Paul Deitel; Harvey Deitel; Abbey Deitel
Edition: 5
Publisher: Prentice Hall
Year: 2013

Language: English
Pages: 1200

About This eBook
Title Page
Copyright Page
Dedication Page
Contents
Preface
Visual C#® 2012, the Visual Studio® 2012 IDE, .NET 4.5, Windows® 7 and Windows® 8
Object-Oriented Programming
Other Features
Training Approach
Obtaining the Software Used in This Book
C# 2012 Fundamentals: Parts I, II, III and IV, Second Edition LiveLessons Video Training
Acknowledgments
About the Authors
Deitel® Dive-Into® Series Corporate Training
Before You Begin
Font and Naming Conventions
Software
Hardware and Software Requirements for the Visual Studio 2012 Express Editions
Viewing File Extensions
Obtaining the Code Examples
Visual Studio Theme
Displaying Line Numbers and Configuring Tabs
Miscellaneous Notes
1. Introduction
1.1. Introduction
1.2. Object Technology
1.3. C#
1.4. Microsoft’s .NET
1.5. Microsoft’s Windows® Operating System
1.6. Windows Phone 8 for Smartphones
1.7. Windows Azure™ and Cloud Computing
1.8. Visual Studio Express 2012 Integrated Development Environment
1.9. Painter Test-Drive in Visual Studio Express 2012 for Windows Desktop
1.10. Painter Test-Drive in Visual Studio Express 2012 for Windows 8
2. Dive Into® Visual Studio Express 2012 for Windows Desktop
2.1. Introduction
2.2. Overview of the Visual Studio Express 2012 IDE
2.3. Menu Bar and Toolbar
2.4. Navigating the Visual Studio IDE
2.5. Using Help
2.6. Using Visual App Development to Create a Simple App that Displays Text and an Image
2.7. Wrap-Up
2.8. Web Resources
3. Introduction to C# Apps
3.1. Introduction
3.2. A Simple C# App: Displaying a Line of Text
3.3. Creating a Simple App in Visual Studio
3.4. Modifying Your Simple C# App
3.5. Formatting Text with Console.Write and Console.WriteLine
3.6. Another C# App: Adding Integers
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. Classes, Objects, Methods, Properties and Instance Variables
4.3. Declaring a Class with a Method and Instantiating an Object of a Class
4.4. Declaring a Method with a Parameter
4.5. Instance Variables and Properties
4.6. UML Class Diagram with a Property
4.7. Software Engineering with Properties and set and get Accessors
4.8. Auto-Implemented Properties
4.9. Value Types vs. Reference Types
4.10. Initializing Objects with Constructors
4.11. Floating-Point Numbers and Type decimal
4.12. 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. while Repetition Statement
5.6. Counter-Controlled Repetition
5.7. Sentinel-Controlled Repetition
5.8. Nested Control Statements
5.9. Compound Assignment Operators
5.10. Increment and Decrement Operators
5.11. Simple Types
5.12. Wrap-Up
6. Control Statements: Part 2
6.1. Introduction
6.2. Essentials of Counter-Controlled Repetition
6.3. for Repetition Statement
6.4. Examples Using the for Statement
6.5. do...while Repetition Statement
6.6. switch Multiple-Selection Statement
6.7. break and continue Statements
6.8. Logical Operators
6.9. 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. Declaring Methods with Multiple Parameters
7.5. Notes on Declaring and Using Methods
7.6. Method-Call Stack and Activation Records
7.7. Argument Promotion and Casting
7.8. The .NET Framework Class Library
7.9. Case Study: Random-Number Generation
7.10. Case Study: A Game of Chance; Introducing Enumerations
7.11. Scope of Declarations
7.12. Method Overloading
7.13. Optional Parameters
7.14. Named Parameters
7.15. Recursion
7.16. Passing Arguments: Pass-by-Value vs. Pass-by-Reference
7.17. 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.5. Case Study: Card Shuffling and Dealing Simulation
8.6. foreach Statement
8.7. Passing Arrays and Array Elements to Methods
8.8. Passing Arrays by Value and by Reference
8.9. Case Study: GradeBook Using an Array to Store Grades
8.10. Multidimensional Arrays
8.11. Case Study: GradeBook Using a Rectangular Array
8.12. Variable-Length Argument Lists
8.13. Using Command-Line Arguments
8.14. Wrap-Up
9. Introduction to LINQ and the List Collection
9.1. Introduction
9.2. Querying an Array of int Values Using LINQ
9.3. Querying an Array of Employee Objects Using LINQ
9.4. Introduction to Collections
9.5. Querying a Generic Collection Using LINQ
9.6. Wrap-Up
9.7. Deitel LINQ Resource Center
10. Classes and Objects: A Deeper Look
10.1. Introduction
10.2. Time Class Case Study
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. Data Abstraction and Encapsulation
10.12. Class View and Object Browser
10.13. Object Initializers
10.14. 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.5. Constructors in Derived Classes
11.6. Software Engineering with Inheritance
11.7. Class object
11.8. Wrap-Up
12. OOP: Polymorphism, Interfaces and Operator Overloading
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.6. sealed Methods and Classes
12.7. Case Study: Creating and Using Interfaces
12.8. Operator Overloading
12.9. 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. 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. (Online) Introduction to Regular Expression
16.16. Wrap-Up
17. Files and Streams
17.1. Introduction
17.2. Data Hierarchy
17.3. Files and Streams
17.4. Classes File and Directory
17.5. Creating a Sequential-Access Text File
17.6. Reading Data from a Sequential-Access Text File
17.7. Case Study: Credit Inquiry Program
17.8. Serialization
17.9. Creating a Sequential-Access File Using Object Serialization
17.10. Reading and Deserializing Data from a Binary File
17.11. Wrap-Up
18. Generics
18.1. Introduction
18.2. Motivation for Generic Methods
18.3. Generic-Method Implementation
18.4. Type Constraints
18.5. Overloading Generic Methods
18.6. Generic Classes
18.7. Wrap-Up
19. Collections
19.1. Introduction
19.2. Collections Overview
19.3. Class Array and Enumerators
19.4. Nongeneric Collections
19.5. Generic Collections
19.6. Covariance and Contravariance for Generic Types
19.7. 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. Web App Development with ASP.NET
21.1. Introduction
21.2. Web Basics
21.3. Multitier App Architecture
21.4. Your First Web App
21.5. Standard Web Controls: Designing a Form
21.6. Validation Controls
21.7. Session Tracking
21.8. Case Study: Database-Driven ASP.NET Guestbook
21.9. Case Study: ASP.NET AJAX
21.10. Case Study: Password-Protected Books Database App
21.11. 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
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. Windows 8 UI and XAML
23.1. Introduction
23.2. Welcome App: Introduction to XAML Declarative GUI Programming
23.3. Painter App: Layouts; Event Handling
23.4. CoverViewer App: Data Binding, Data Templates and Styles
23.5. App Lifecycle
23.6. Wrap-Up
24. Windows 8 Graphics and Multimedia
24.1. Introduction
24.2. Basic Shapes
24.3. Polylines and Polygons
24.4. SolidColorBrushes and ImageBrushes
24.5. GradientBrushes
24.6. Transforms
24.7. Windows 8 Customization: A Television GUI
24.8. Wrap-Up
25. Building a Windows Phone 8 App
25.1. Introduction
25.2. Downloading the Windows Phone 8 SDK
25.3. Tip Calculator App Introduction
25.4. Test-Driving the Tip Calculator App
25.5. Tip Calculator Technologies Overview
25.6. Building the App’s GUI
25.7. Adding Functionality to the App with C#
25.8. WMAppManifest.xml
25.9. Windows Phone Dev Center
25.10. Selling Your Apps in the Windows Phone Marketplace
25.11. Other Popular Mobile App Platforms
25.12. Developer Documentation
25.13. Additional Windows Phone 8 Resources
25.14. Wrap-Up
26. Asynchronous Programming with async and await
26.1. Introduction
26.2. Basics of async and await
26.3. Executing an Asynchronous Task from a GUI App
26.4. Sequential Execution of Two Compute-Intensive Tasks
26.5. Asynchronous Execution of Two Compute-Intensive Tasks
26.6. Invoking a Flickr Web Service Asynchronously with WebClient
26.7. Wrap-Up
27. Web App Development with ASP.NET: A Deeper Look
27.1. Introduction
27.2. Case Study: Password-Protected Books Database App
27.3. ASP.NET Ajax
27.4. Wrap-Up
28. Web Services
28.1. Introduction
28.2. WCF Services Basics
28.3. HTTP get and post Requests
28.4. Representational State Transfer (REST)
28.5. JavaScript Object Notation (JSON)
28.6. Publishing and Consuming REST-Based XML Web Services
28.7. Publishing and Consuming REST-Based JSON Web Services
28.8. Equation Generator: Returning User-Defined Types
28.9. Wrap-Up
29. Building a Windows Azure™ Cloud Computing App
29.1. Introduction
29.2. Installing the Windows Azure SDK for Visual Studio 2012
29.3. Windows Azure Cloud Services Accounts
29.4. Favorite Twitter Searches: Introduction
29.5. Favorite Twitter Searches: Test-Drive
29.6. Favorite Twitter Searches: Technologies Overview
29.7. Favorite Twitter Searches: Code
29.8. Security, Privacy and Reliability
29.9. Microsoft Windows Azure Resources
29.10. Microsoft Windows Azure Code Samples
29.11. Additional Web Resources
29.12. Wrap-Up
30. GUI with Windows Presentation Foundation
30.1. Introduction
30.2. Windows Presentation Foundation (WPF)
30.3. Declarative GUI Programming Using XAML
30.4. Creating a WPF App
30.5. Laying Out Controls
30.6. Event Handling
30.7. Commands and Common Application Tasks
30.8. WPF GUI Customization
30.9. Using Styles to Change the Appearance of Controls
30.10. Customizing Windows
30.11. Defining a Control’s Appearance with Control Templates
30.12. Data-Driven GUIs with Data Binding
30.13. Wrap-Up
31. WPF Graphics and Multimedia
31.1. Introduction
31.2. Controlling Fonts
31.3. Basic Shapes
31.4. Polygons and Polylines
31.5. Brushes
31.6. Transforms
31.7. WPF Customization: A Television GUI
31.8. Animations
31.9. Speech Synthesis and Speech Recognition
31.10. Wrap-Up
32. ATM Case Study, Part 1: Object-Oriented Design with the UML
32.1. Introduction
32.2. Examining the ATM Requirements Document
32.3. Identifying the Classes in the ATM Requirements Document
32.4. Identifying Class Attributes
32.5. Identifying Objects’ States and Activities
32.6. Identifying Class Operations
32.7. Identifying Collaboration Among Objects
32.8. Wrap-Up
33. ATM Case Study, Part 2: Implementing an OO Design
33.1. Introduction
33.2. Starting to Program the Classes of the ATM System
33.3. Incorporating Inheritance and Polymorphism into the ATM System
33.4. ATM Case Study Implementation
33.5. Wrap-Up
A. Operator Precedence Chart
B. Simple Types
Additional Simple Type Information
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
E.1. Introduction
E.2. Additional Diagram Types
F. Unicode®
F.1. Introduction
F.2. Unicode Transformation Formats
F.3. Characters and Glyphs
F.4. Advantages/Disadvantages of Unicode
F.5. Using Unicode
F.6. Character Ranges
Index