did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780133440577

C# 2012 for Programmers

by ;
  • ISBN13:

    9780133440577

  • ISBN10:

    0133440575

  • Edition: 5th
  • Format: Paperback
  • Copyright: 2013-09-27
  • Publisher: Prentice Hall
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99

Summary

The professional programmer’s Deitel® guide to  C# 2012 and object-oriented development for  Windows® 7 and Windows® 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® 8 UI and WPF graphics and multimedia, web services, Windows® Phone 8, Windows Azure™ and more. You’ll enjoy the treatment of object-oriented programming and an OOD/UML® 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®, C++, Visual C++®, C, Java™, Android™ app development, iOS® app development, Internet and web programming, JavaScript®, XML, Perl®, 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® ATM Case Study

•            WinForms, WPF, Windows® 8 UI, XAML, Event Handling, Visual C# Debugging

•            WPF and Windows® 8 Graphics  and Multimedia

•            Windows® Phone 8, Cloud Computing with Windows Azure™, 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® Series  programming training courses delivered at organizations worldwide visit www.deitel.com/training or write to deitel@deitel.com
  • Download code examples
  • Join the Deitel social networking communities on Facebook®  at facebook.com/DeitelFan, Twitter® @deitel, Google+™ at  gplus.to/deitel and LinkedIn®  at bit.ly/DeitelLinkedIn.
  • To receive updates for this book, subscribe to the Deitel® Buzz Online e-mail newsletter at www.deitel.com/newsletter/ subscribe.html

 

 

Table of Contents

&>

Preface xxiii

Before You Begin xxxi

 

Chapter 1: Introduction 1

1.1 Introduction 2

1.2 Object Technology 2

1.3 C# 5 Object-Oriented Programming 5

1.4 Microsoft’s .NET 6

1.5 Microsoft’s Windows® Operating System 8

1.6 Windows Phone 8 for Smartphones 9

1.7 Windows Azure™and Cloud Computing 11

1.8 Visual Studio Express 2012 Integrated Development Environment 11

1.9 Painter Test-Drive in Visual Studio Express 2012 for Windows Desktop 11

1.10 Painter Test-Drive in Visual Studio Express 2012 for Windows 8 15

 

Chapter 2: Dive Into® Visual Studio Express 2012 for Windows Desktop 20

2.1 Introduction 21

2.2 Overview of the Visual Studio Express 2012 IDE 21

2.3 Menu Bar and Toolbar 26

2.4 Navigating the Visual Studio IDE 28

2.5 Using Help 33

2.6 Using Visual App Development to Create a Simple App that Displays Text and an Image 34

2.7 Wrap-Up 44

2.8 Web Resources 45

 

Chapter 3: Introduction to C# Apps 46

3.1 Introduction 47

3.2 ASimple C# App: Displaying a Line of Text 47

3.3 Creating a Simple App in Visual Studio 52

3.4 Modifying Your Simple C# App 58

3.5 Formatting Text with Console.Write and Console.WriteLine 60

3.6 Another C# App: Adding Integers 61

3.7 Arithmetic 65

3.8 Decision Making: Equality and Relational Operators 67

3.9 Wrap-Up 71

 

Chapter 4: Introduction to Classes, Objects, Methods and strings 72

4.1 Introduction 73

4.2 Classes, Objects, Methods, Properties and Instance Variables 73

4.3 Declaring a Class with a Method and Instantiating an Object of a Class 74

4.4 Declaring a Method with a Parameter 78

4.5 Instance Variables and Properties 82

4.6 UML Class Diagram with a Property 86

4.7 Software Engineering with Properties and set and get Accessors 87

4.8 Auto-Implemented Properties 88

4.9 Value Types vs. Reference Types 89

4.10 Initializing Objects with Constructors 90

4.11 Floating-Point Numbers and Type decimal 93

4.12 Wrap-Up 99

 

Chapter 5: Control Statements: Part 1 101

5.1 Introduction 102

5.2 Control Structures 102

5.3 if Single-Selection Statement 104

5.4 if…else Double-Selection Statement 105

5.5 while Repetition Statement 109

5.6 Counter-Controlled Repetition 110

5.7 Sentinel-Controlled Repetition 113

5.8 Nested Control Statements 118

5.9 Compound Assignment Operators 121

5.10 Increment and Decrement Operators 122

5.11 Simple Types 125

5.12 Wrap-Up 125

 

Chapter 6: Control Statements: Part 2 126

6.1 Introduction 127

6.2 Essentials of Counter-Controlled Repetition 127

6.3 for Repetition Statement 128

6.4 Examples Using the for Statement 132

6.5 do…while Repetition Statement 136

6.6 switch Multiple-Selection Statement 137

6.7 break and continue Statements 145

6.8 Logical Operators 147

6.9 Wrap-Up 153

 

Chapter 7: Methods: A Deeper Look 154

7.1 Introduction 155

7.2 Packaging Code in C# 155

7.3 static Methods, static Variables and Class Math 156

7.4 Declaring Methods with Multiple Parameters 158

7.5 Notes on Declaring and Using Methods 162

7.6 Method-Call Stack and Activation Records 163

7.7 Argument Promotion and Casting 163

7.8 The .NET Framework Class Library 165

7.9 Case Study: Random-Number Generation 167

7.10 Case Study: A Game of Chance; Introducing Enumerations 172

7.11 Scope of Declarations 177

7.12 Method Overloading 179

7.13 Optional Parameters 182

7.14 Named Parameters 183

7.15 Recursion 184

7.16 Passing Arguments: Pass-by-Value vs. Pass-by-Reference 187

7.17 Wrap-Up 191

 

Chapter 8: Arrays; Introduction to Exception Handling 192

8.1 Introduction 193

8.2 Arrays 193

8.3 Declaring and Creating Arrays 195

8.4 Examples Using Arrays 196

8.5 Case Study: Card Shuffling and Dealing Simulation 206

8.6 foreach Statement 210

8.7 Passing Arrays and Array Elements to Methods 212

8.8 Passing Arrays by Value and by Reference 214

8.9 Case Study: GradeBook Using an Array to Store Grades 218

8.10 Multidimensional Arrays 223

8.11 Case Study: GradeBook Using a Rectangular Array 228

8.12 Variable-Length Argument Lists 234

8.13 Using Command-Line Arguments 236

8.14 Wrap-Up 238

 

Chapter 9: Introduction to LINQ and the List Collection 239

9.1 Introduction 240

9.2 Querying an Array of int Values Using LINQ 241

9.3 Querying an Array of Employee Objects Using LINQ 245

9.4 Introduction to Collections 250

9.5 Querying a Generic Collection Using LINQ 253

9.6 Wrap-Up 255

9.7 Deitel LINQ Resource Center 255

 

Chapter 10: Classes and Objects: A Deeper Look 256

10.1 Introduction 257

10.2 Time Class Case Study 257

10.3 Controlling Access to Members 261

10.4 Referring to the Current Object’s Members with the this Reference 262

10.5 Time Class Case Study: Overloaded Constructors 264

10.6 Default and Parameterless Constructors 270

10.7 Composition 271

10.8 Garbage Collection and Destructors 274

10.9 static Class Members 275

10.10 readonly Instance Variables 278

10.11 Data Abstraction and Encapsulation 279

10.12 Class View and Object Browser 281

10.13 Object Initializers 283

10.14 Wrap-Up 283

 

Chapter 11: Object-Oriented Programming: Inheritance 285

11.1 Introduction 286

11.2 Base Classes and Derived Classes 287

11.3 protected Members 289

11.4 Relationship between Base Classes and Derived Classes 290

11.5 Constructors in Derived Classes 313

11.6 Software Engineering with Inheritance 314

11.7 Class object 314

11.8 Wrap-Up 315

 

Chapter 12: OOP: Polymorphism, Interfaces and Operator Overloading 317

12.1 Introduction 318

12.2 Polymorphism Examples 320

12.3 Demonstrating Polymorphic Behavior 321

12.4 Abstract Classes and Methods 324

12.5 Case Study: Payroll System Using Polymorphism 326

12.6 sealed Methods and Classes 342

12.7 Case Study: Creating and Using Interfaces 342

12.8 Operator Overloading 353

12.9 Wrap-Up 356

 

Chapter 13: Exception Handling: A Deeper Look 358

13.1 Introduction 359

13.2 Example: Divide by Zero without Exception Handling 360

13.3 Example: Handling DivideByZeroExceptions and FormatExceptions 363

13.4 .NET Exception Hierarchy 368

13.5 finally Block 369

13.6 The using Statement 376

13.7 Exception Properties 377

13.8 User-Defined Exception Classes 381

13.9 Wrap-Up 385

 

Chapter 14: Graphical User Interfaces with Windows Forms: Part 1 386

14.1 Introduction 387

14.2 Windows Forms 388

14.3 Event Handling 390

14.4 Control Properties and Layout 397

14.5 Labels, TextBoxes and Buttons 401

14.6 GroupBoxes and Panels 404

14.7 CheckBoxes and RadioButtons 407

14.8 PictureBoxes 415

14.9 ToolTips 417

14.10 NumericUpDown Control 419

14.11 Mouse-Event Handling 421

14.12 Keyboard-Event Handling 424

14.13 Wrap-Up 427

 

Chapter 15: Graphical User Interfaces with Windows Forms: Part 2 428

15.1 Introduction 429

15.2 Menus 429

15.3 MonthCalendar Control 438

15.4 DateTimePicker Control 439

15.5 LinkLabel Control 442

15.6 ListBox Control 446

15.7 CheckedListBox Control 450

15.8 ComboBox Control 453

15.9 TreeView Control 457

15.10 ListView Control 462

15.11 TabControl Control 468

15.12 Multiple Document Interface (MDI) Windows 473

15.13 Visual Inheritance 480

15.14 User-Defined Controls 485

15.15 Wrap-Up 489

 

Chapter 16: Strings and Characters: A Deeper Look 490

16.1 Introduction 491

16.2 Fundamentals of Characters and Strings 492

16.3 string Constructors 493

16.4 string Indexer, Length Property and CopyTo Method 494

16.5 Comparing strings 495

16.6 Locating Characters and Substrings in strings 498

16.7 Extracting Substrings from strings 501

16.8 Concatenating strings 502

16.9 Miscellaneous string Methods 503

16.10 Class StringBuilder 504

16.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder 505

16.12 Append and AppendFormat Methods of Class StringBuilder 507

16.13 Insert, Remove and Replace Methods of Class StringBuilder 509

16.14 Char Methods 512

16.15 (Online) Introduction to Regular Expressions 514

16.16 Wrap-Up 515

 

Chapter 17: Files and Streams 516

17.1 Introduction 517

17.2 Data Hierarchy 517

17.3 Files and Streams 519

17.4 Classes File and Directory 520

17.5 Creating a Sequential-Access Text File 529

17.6 Reading Data from a Sequential-Access Text File 538

17.7 Case Study: Credit Inquiry Program 542

17.8 Serialization 548

17.9 Creating a Sequential-Access File Using Object Serialization 549

17.10 Reading and Deserializing Data from a Binary File 553

17.11 Wrap-Up 555

 

Chapter 18: Generics 557

18.1 Introduction 558

18.2 Motivation for Generic Methods 559

18.3 Generic-Method Implementation 561

18.4 Type Constraints 564

18.5 Overloading Generic Methods 566

18.6 Generic Classes 567

18.7 Wrap-Up 576

 

Chapter 19: Collections 577

19.1 Introduction 578

19.2 Collections Overview 578

19.3 Class Array and Enumerators 581

19.4 Nongeneric Collections 584

19.5 Generic Collections 596

19.6 Covariance and Contravariance for Generic Types 603

19.7 Wrap-Up 606

 

Chapter 20: Databases and LINQ 607

20.1 Introduction 608

20.2 Relational Databases 609

20.3 A Books Database 610

20.4 LINQ to Entities and the ADO.NET Entity Framework 614

20.5 Querying a Database with LINQ 615

20.6 Dynamically Binding Query Results 627

20.7 Retrieving Data from Multiple Tables with LINQ 632

20.8 Creating a Master/Detail View App 637

20.9 Address Book Case Study 641

20.10 Tools and Web Resources 647

20.11 Wrap-Up 647

 

Chapter 21: Web App Development with ASP.NET 649

21.1 Introduction 650

21.2 Web Basics 651

21.3 Multitier App Architecture 652

21.4 Your First Web App 654

21.5 Standard Web Controls: Designing a Form 666

21.6 Validation Controls 670

21.7 Session Tracking 677

21.8 Case Study: Database-Driven ASP.NET Guestbook 685

21.9 Case Study: ASP.NET AJAX 693

21.10 Case Study: Password-Protected Books Database App 694

21.11 Wrap-Up 694

 

Chapter 22: XML and LINQ to XML 695

22.1 Introduction 696

22.2 XML Basics 696

22.3 Structuring Data 699

22.4 XML Namespaces 705

22.5 Document Type Definitions (DTDs) 708

22.6 W3C XML Schema Documents 711

22.7 Extensible Stylesheet Language and XSL Transformations 719

22.8 LINQ to XML: Document Object Model (DOM) 728

22.9 LINQ to XML Class Hierarchy 731

22.10 LINQ to XML: Namespaces and Creating Documents 740

22.11 XSLT with Class XslCompiledTransform 744

22.12 Wrap-Up 746

 

Chapter 23: Windows 8 UI and XAML 747

23.1 Introduction 748

23.2 Welcome App: Introduction to XAML Declarative GUI Programming 749

23.3 Painter App: Layouts; Event Handling 758

23.4 CoverViewer App: Data Binding, Data Templates and Styles 771

23.5 App Lifecycle 778

23.6 Wrap-Up 779

 

Chapter 24: Windows 8 Graphics and Multimedia 780

24.1 Introduction 781

24.2 Basic Shapes 782

24.3 Polylines and Polygons 784

24.4 SolidColorBrushes and ImageBrushes 786

24.5 GradientBrushes 788

24.6 Transforms 794

24.7 Windows 8 Customization: A Television GUI 797

24.8 Wrap-Up 807

 

Chapter 25: Building a Windows Phone 8 App 808

25.1 Introduction 809

25.2 Downloading the Windows Phone 8 SDK 810

25.3 Tip Calculator App Introduction 811

25.4 Test-Driving the Tip Calculator App 812

25.5 Tip Calculator Technologies Overview 812

25.6 Building the App’s GUI 813

25.7 Adding Functionality to the App with C# 820

25.8 WMAppManifest.xml 825

25.9 Windows Phone Dev Center 825

25.10 Selling Your Apps in the Windows Phone Marketplace 827

25.11 Other Popular Mobile App Platforms 828

25.12 Developer Documentation 829

25.13 Additional Windows Phone 8 Resources 829

25.14 Wrap-Up 831

 

Chapter 26: Asynchronous Programming with async and await 832

26.1 Introduction 833

26.2 Basics of async and await 834

26.3 Executing an Asynchronous Task from a GUI App 835

26.4 Sequential Execution of Two Compute-Intensive Tasks 839

26.5 Asynchronous Execution of Two Compute-Intensive Tasks 841

26.6 Invoking a Flickr Web Service Asynchronously with WebClient 846

26.7 Wrap-Up 852

 

Chapter 27: Web App Development with ASP.NET: A Deeper Look 854

27.1 Introduction 855

27.2 Case Study: Password-Protected Books Database App 855

27.3 ASP.NET Ajax 871

27.4 Wrap-Up 877

 

Chapter 28: Web Services 879

28.1 Introduction 880

28.2 WCF Services Basics 881

28.3 HTTP get and post Requests 881

28.4 Representational State Transfer (REST) 882

28.5 JavaScript Object Notation (JSON) 882

28.6 Publishing and Consuming REST-Based XML Web Services 883

28.7 Publishing and Consuming REST-Based JSON Web Services 889

28.8 Equation Generator: Returning User-Defined Types 893

28.9 Wrap-Up 905

 

Chapter 29: Building a Windows Azure™ Cloud Computing App 906

29.1 Introduction 907

29.2 Installing the Windows Azure SDK for Visual Studio 2012 909

29.3 Windows Azure Cloud Services Accounts 909

29.4 Favorite Twitter Searches: Introduction 910

29.5 Favorite Twitter Searches: Test-Drive 911

29.6 Favorite Twitter Searches: Technologies Overview 914

29.7 Favorite Twitter Searches: Code 915

29.8 Security, Privacy and Reliability 921

29.9 Microsoft Windows Azure Resources 921

29.10 Microsoft Windows Azure Code Samples 923

29.11 Additional Web Resources 924

29.12 Wrap-Up 926

 

Chapter 30: GUI with Windows Presentation Foundation 927

30.1 Introduction 928

30.2 Windows Presentation Foundation (WPF) 928

30.3 Declarative GUI Programming Using XAML 929

30.4 Creating a WPF App 931

30.5 Laying Out Controls 932

30.5.1 General Layout Principles 933

30.5.2 Layout in Action 934

30.6 Event Handling 938

30.7 Commands and Common Application Tasks 946

30.8 WPF GUI Customization 951

30.9 Using Styles to Change the Appearance of Controls 951

30.10 Customizing Windows 957

30.11 Defining a Control’s Appearance with Control Templates 960

30.12 Data-Driven GUIs with Data Binding 965

30.13 Wrap-Up 971

 

Chapter 31: WPF Graphics and Multimedia 972

31.1 Introduction 973

31.2 Controlling Fonts 973

31.3 Basic Shapes 975

31.4 Polygons and Polylines 977

31.5 Brushes 980

31.6 Transforms 987

31.7 WPF Customization: A Television GUI 989

31.8 Animations 999

31.9 Speech Synthesis and Speech Recognition 1001

31.10 Wrap-Up 1008

 

Chapter 32: ATM Case Study, Part 1: Object-Oriented Design with the UML 1009

32.1 Introduction 1010

32.2 Examining the ATM Requirements Document 1010

32.3 Identifying the Classes in the ATM Requirements Document 1018

32.4 Identifying Class Attributes 1025

32.5 Identifying Objects’ States and Activities 1029

32.6 Identifying Class Operations 1033

32.7 Identifying Collaboration Among Objects 1040

32.8 Wrap-Up 1047

 

Chapter 33: ATM Case Study, Part 2: Implementing an Object-Oriented Design 1052

33.1 Introduction 1053

33.2 Starting to Program the Classes of the ATM System 1053

33.3 Incorporating Inheritance and Polymorphism into the ATM System 1058

33.4 ATM Case Study Implementation 1065

33.5 Wrap-Up 1089

 

Appendix A: Operator Precedence Chart 1092

 

Appendix B: Simple Types 1094

 

Appendix C: ASCII Character Set 1096

 

Appendix D: Number Systems 1097

D.1 Introduction 1098

D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 1101

D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 1102

D.4 Converting from Binary, Octal or Hexadecimal to Decimal 1102

D.5 Converting from Decimal to Binary, Octal or Hexadecimal 1103

D.6 Negative Binary Numbers: Two’s Complement Notation 1105

 

Appendix E: UML 2: Additional Diagram Types 1107

E.1 Introduction 1107

E.2 Additional Diagram Types 1107

 

Appendix F: Unicode® 1109

F.1 Introduction 1110

F.2 Unicode Transformation Formats 1111

F.3 Characters and Glyphs 1112

F.4 Advantages/Disadvantages of Unicode 1112

F.5 Using Unicode 1113

F.6 Character Ranges 1115

 

Index 1117

 

 

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program