- ホーム
- > 洋書
- > 英文書
- > Computer / Languages
Full Description
The professional programmer's Deitel (R) guide to C# 2010 and the powerful Microsoft (R) .NET 4 FrameworkWritten for programmers with a background in C++, Java or other high-level, object-oriented languages, this book applies the Deitel signature live-code approach to teaching programming and explores Microsoft's C# 2010 language and .NET 4 in depth. The book is updated for Visual Studio (R) 2010 and C# 4, and presents C# concepts in the context of fully tested programs, complete with syntax shading, detailed line-by-line code descriptions and program outputs. The book features 200+ C# applications with 17,000+ lines of proven C# code, as well as hundreds of programming tips that will help you build robust applications. Start with a concise introduction to C# fundamentals using an early classes and objects approach, then rapidly move on to more advanced topics, including multithreading, .NET 4, LINQ, WPF, ASP.NET 4, WCF web services and Silverlight (R). Along the way you'll enjoy the Deitels' classic treatment of object-oriented programming and the OOD/UML (R) ATM case study, including a complete C# implementation. When you're finished, you'll be ready to build next-generation Windows applications, web applications and web services. Check out the related LiveLessons video product, C# 2010 Fundamentals: Parts I, II and III, containing 20+ hours of video synchronized to this book: www.deitel.com/livelessons. Practical, example-rich coverage of:.NET 4, Types, Arrays, Exception Handling LINQ, Object/Collection Initializers OOP: Classes, Objects, Inheritance, Polymorphism, Interfaces WinForms, WPF, XAML, Event Handling WPF GUI/Graphics/Multimedia Silverlight (R) Lists, Queues, Stacks, Trees Generic Collections, Methods and Classes XML (R), LINQ to XML Database, LINQ to SQL ASP.NET 4.0, ASP.NET AJAX Web Forms, Web Controls WCF Web Services OOD/UML (R) Case Study Visit www.deitel.comFor information on Deitel's Dive Into (R) training courses offered worldwide visit www.deitel.com/training To license Deitel book and/or LiveLessons video content for your learning management system, e-mail deitel@deitel.com Download code examples Follow Deitel on Twitter (R) @deitel and Facebook (R) at www.deitel.com/deitelfan/ To receive updates for this book, subscribe to the free Deitel (R) Buzz Online e-mail newsletter at www.deitel.com/newsletter/subscribe.html Testimonials from the Third and Fourth Edition Reviewers"Takes you from zero to the highest levels of C# programming proficiency. The pedagogical approach and wealth of online material guarantee this book an outstanding place among its peers. The best presentation on inheritance, interfaces and polymorphism I have seen in my 25+ years as a trainer and consultant! Superbly clear." -Octavio Hernandez, Microsoft C# MVP, Advanced Bionics "The ultimate, comprehensive book that teaches you how to program using the latest Microsoft technologies. Excellent explanations, lots of examples, all the necessary theoretical background and all the latest technologies for desktop, web and databases. The best overview of Silverlight." -Kirill Osenkov, Visual Studio Languages Team, Microsoft "Illustrates the best practices of C# programming." -Mingsheng Hong, Cornell University "Excellent introduction to the world of .NET for the beginning C# programmer, using the Deitels' live-code approach and real-world examples." -Bonnie Berent, Microsoft C# MVP "Shows the practical application of the most recent topics in C# development. A gentle introduction to LINQ and the .NET collection classes; I like it very much! Shows a lot of useful basic techniques and most of the `second level facts' needed to develop WinForms apps. I like the way you introduce working with databases using LINQ to SQL. Excellent introduction to ASP.NET. A very good introduction to generics. Outstanding chapter on collections; the discussion of the new co- and contra-variance capabilities is by necessity short, but very nice." -Octavio Hernandez, Microsoft C# MVP, Advanced Bionics "The code examples provide a very good start on C# programming. A good job explaining the concepts of classes and objects in plain English. The arrays chapter is well done. A nice introduction to LINQ and Collections. The code examples in the chapter on polymorphism and interfaces are excellent. Important exception-related topics are explained with good examples." -Zijiang (James) Yang, Western Michigan University "Teaches how to `program in the large,' with material on object-oriented programming and software engineering principles." -Mingsheng Hong, Cornell University "An excellent, true objects-first book. Excellent introduction to data structures and collections. The generics material is a real asset." -Gavin Osborne, Saskatchewan Institute of Applied Science and Technology "Great chapter on polymorphism." -Eric Lippert, Microsoft "Excellent chapter on exceptions. Very good chapter on Winforms GUIs." -Marcelo Guerra Hahn, Microsoft "Updated contents cover the most important additions to the language while maintaining the Deitels' well-known high-quality. The early introduction to classes and objects is brilliant. I especially like the explanation of properties, and the discussion of value types vs. reference types. [Classes and Objects: A Deeper Look] does a really good job providing good practices for accessing private data and reusing code. The [Data Structures] chapter is very well written. Coverage of ASP.NET is exceptional." -Jose Antonio Gonzalez Seco, Parliament of Andalusia, Spain "Perfect for professionals. Thorough introductions to the debugger and LINQ." -Vinay Ahuja, Architect, Microsoft Corporation "The TV/Video Viewer will enthuse readers and help them see how graphics effects can be created easily in WPF." -Ged Mead, Microsoft MVP, DevCity.Net "An excellent introduction to XML, LINQ to XML and related technologies."-Helena Kotas, Microsoft "Good overview of relational databases. It hits on the right LINQ to SQL idioms." -Alex Turner, Microsoft "Great overview of producing and consuming web services with WCF." -Dan Crevier, Microsoft [Chapter 24: GUI with Windows Presentation Foundation] "This chapter is very well written. I especially liked your coverage of GUI customization and data bindings, which is very clear." -Jose Antonio Gonzalez Seco, Parliament of Andalusia, Spain [Chapter 24: GUI with Windows Presentation Foundation] "Excellent chapter! Everything is laid out right so that every required bit of knowledge is already there when needed." -Octavio Hernandez, Microsoft C# MVP, Advanced Bionics [Chapter 25: WPF Graphics and Multimedia] "An already excellent chapter that got even better! This chapter perfectly complements the previous one, and offers great examples and explanations. The new example on speech synthesis and speech recognition is very nice, and the very first I've seen in any C# book to date." -Octavio Hernandez, Microsoft C# MVP, Advanced Bionics [Chapter 26: XML and LINQ to XML] "Excellent chapter! The presentation of LINQ to XML is fabulous!" -Octavio Hernandez, Microsoft C# MVP, Advanced Bionics
Contents
Preface xxi Before You Begin xxxiv Chapter 111.1 Introduction 21.2 Microsoft's Windows (R) Operating System 21.3 C, C++, Objective-C and Java 31.4 C# 31.5 Extensible Markup Language (XML) 41.6 Introduction to Microsoft .NET 41.7 The .NET Framework and the Common Language Runtime 41.8 Test-Driving the Advanced Painter Application 51.9 Introduction to Object Technology 81.10 Wrap-Up 10 Chapter 2: Dive Into (R) Visual C# 2010 Express 112.1 Introduction 122.2 Overview of the Visual Studio 2010 IDE 122.3 Menu Bar and Toolbar 172.4 Navigating the Visual Studio IDE 192.5 Using Help 242.6 Using Visual Programming to Create a Simple Program that Displays Text and an Image 272.7 Wrap-Up 382.8 Web Resources 39 Chapter 3: Introduction to C# Applications 403.1 Introduction 413.2 A Simple C# Application: Displaying a Line of Text 413.3 Creating a Simple Application in Visual C# Express 463.4 Modifying Your Simple C# Application 533.5 Formatting Text with Console.Write and Console.WriteLine 563.6 Another C# Application: Adding Integers 573.7 Arithmetic 593.8 Decision Making: Equality and Relational Operators 613.9 Wrap-Up 65 Chapter 4: Introduction to Classes and Objects 664.1 Introduction 674.2 Classes, Objects, Methods, Properties and Instance Variables 674.3 Declaring a Class with a Method and Instantiating an Object of a Class 684.4 Declaring a Method with a Parameter 724.5 Instance Variables and Properties 754.6 UML Class Diagram with a Property 804.7 Software Engineering with Properties and set and get Accessors 814.8 Auto-Implemented Properties 824.9 Value Types vs. Reference Types 834.10 Initializing Objects with Constructors 844.11 Floating-Point Numbers and Type decimal 874.12 Wrap-Up 93 Chapter 5: Control Statements: Part 1 945.1 Introduction 955.2 Control Structures 955.3 if Single-Selection Statement 975.4 if...else Double-Selection Statement 985.5 while Repetition Statement 1025.6 Counter-Controlled Repetition 1035.7 Sentinel-Controlled Repetition 1075.8 Nested Control Statements 1125.9 Compound Assignment Operators 1155.10 Increment and Decrement Operators 1155.11 Simple Types 1185.12 Wrap-Up 119 Chapter 6: Control Statements: Part 2 1206.1 Introduction 1216.2 Essentials of Counter-Controlled Repetition 1216.3 for Repetition Statement 1226.4 Examples Using the for Statement 1276.5 do...while Repetition Statement 1316.6 switch Multiple-Selection Statement 1326.7 break and continue Statements 1406.8 Logical Operators 1426.9 Wrap-Up 148 Chapter 7: Methods: A Deeper Look 1497.1 Introduction 1507.2 Packaging Code in C# 1507.3 static Methods, static Variables and Class Math 1517.4 Declaring Methods with Multiple Parameters 1547.5 Notes on Declaring and Using Methods 1577.6 Method-Call Stack and Activation Records 1587.7 Argument Promotion and Casting 1597.8 The .NET Framework Class Library 1607.9 Case Study: Random-Number Generation 1627.10 Case Study: A Game of Chance (Introducing Enumerations) 1677.11 Scope of Declarations 1727.12 Method Overloading 1747.13 Optional Parameters 1777.14 Named Parameters 1787.15 Recursion 1797.16 Passing Arguments: Pass-by-Value vs. Pass-by-Reference 1827.17 Wrap-Up 185 Chapter 8: Arrays 1878.1 Introduction 1888.2 Arrays 1888.3 Declaring and Creating Arrays 1898.4 Examples Using Arrays 1908.5 Case Study: Card Shuffling and Dealing Simulation 1998.6 foreach Statement 2038.7 Passing Arrays and Array Elements to Methods 2058.8 Passing Arrays by Value and by Reference 2088.9 Case Study: Class GradeBook Using an Array to Store Grades 2128.10 Multidimensional Arrays 2178.11 Case Study: GradeBook Using a Rectangular Array 2228.12 Variable-Length Argument Lists 2278.13 Using Command-Line Arguments 2298.14 Wrap-Up 231 Chapter 9: Introduction to LINQ and the List Collection 2329.1 Introduction 2339.2 Querying an Array of int Values Using LINQ 2349.3 Querying an Array of Employee Objects Using LINQ 2389.4 Introduction to Collections 2439.5 Querying a Generic Collection Using LINQ 2469.6 Wrap-Up 2489.7 Deitel LINQ Resource Center 248 Chapter 10: Classes and Objects: A Deeper Look 24910.1 Introduction 25010.2 Time Class Case Study 25010.3 Controlling Access to Members 25410.4 Referring to the Current Object's Members with the this Reference 25510.5 Indexers 25710.6 Time Class Case Study: Overloaded Constructors 26110.7 Default and Parameterless Constructors 26710.8 Composition 26710.9 Garbage Collection and Destructors 27010.10 static Class Members 27110.11 readonly Instance Variables 27510.12 Data Abstraction and Encapsulation 27610.13 Time Class Case Study: Creating Class Libraries 27710.14 internal Access 28210.15 Class View and Object Browser 28310.16 Object Initializers 28510.17 Time Class Case Study: Extension Methods 28810.18 Delegates 29110.19 Lambda Expressions 29310.20 Anonymous Types 29610.21 Wrap-Up 298 Chapter 11: Object-Oriented Programming: Inheritance 30011.1 Introduction 30111.2 Base Classes and Derived Classes 30211.3 protected Members 30411.4 Relationship between Base Classes and Derived Classes 30511.5 Constructors in Derived Classes 32911.6 Software Engineering with Inheritance 32911.7 Class object 33011.8 Wrap-Up 331 Chapter 12: OOP: Polymorphism, Interfaces and Operator Overloading 33212.1 Introduction 33312.2 Polymorphism Examples 33512.3 Demonstrating Polymorphic Behavior 33612.4 Abstract Classes and Methods 33912.5 Case Study: Payroll System Using Polymorphism 34112.6 sealed Methods and Classes 35712.7 Case Study: Creating and Using Interfaces 35712.8 Operator Overloading 36812.9 Wrap-Up 371 Chapter 13: Exception Handling 37213.1 Introduction 37313.2 Example: Divide by Zero without Exception Handling 37313.3 Example: Handling DivideByZeroExceptions and FormatExceptions 37613.4 .NET Exception Hierarchy 38113.5 finally Block 38313.6 The using Statement 38913.7 Exception Properties 39013.8 User-Defined Exception Classes 39513.9 Wrap-Up 398 Chapter 14: Graphical User Interfaces with Windows Forms: Part 1 39914.1 Introduction 40014.2 Windows Forms 40114.3 Event Handling 40314.4 Control Properties and Layout 41014.5 Labels, TextBoxes and Buttons 41414.6 GroupBoxes and Panels 41714.7 CheckBoxes and RadioButtons 42014.8 PictureBoxes 42814.9 ToolTips 43014.10 NumericUpDown Control 43214.11 Mouse-Event Handling 43414.12 Keyboard-Event Handling 43714.13 Wrap-Up 440 Chapter 15: Graphical User Interfaces with Windows Forms: Part 2 44115.1 Introduction 44215.2 Menus 44215.3 MonthCalendar Control 45115.4 DateTimePicker Control 45215.5 LinkLabel Control 45515.6 ListBox Control 45915.7 CheckedListBox Control 46315.8 ComboBox Control 46615.9 TreeView Control 47015.10 ListView Control 47515.11 TabControl Control 48115.12 Multiple Document Interface (MDI) Windows 48615.13 Visual Inheritance 49315.14 User-Defined Controls 49815.15 Wrap-Up 502 Chapter 16: Strings and Characters 50416.1 Introduction 50516.2 Fundamentals of Characters and Strings 50616.3 string Constructors 50716.4 string Indexer, Length Property and CopyTo Method 50816.5 Comparing strings 50916.6 Locating Characters and Substrings in strings 51216.7 Extracting Substrings from strings 51516.8 Concatenating strings 51616.9 Miscellaneous string Methods 51716.10 Class StringBuilder 51816.11 Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder 51916.12 Append and AppendFormat Methods of Class StringBuilder 52116.13 Insert, Remove and Replace Methods of Class StringBuilder 52316.14 Char Methods 52616.15 Regular Expressions 52816.16 Wrap-Up 542 Chapter 17: Files and Streams 54317.1 Introduction 54417.2 Data Hierarchy 54417.3 Files and Streams 54617.4 Classes File and Directory 54717.5 Creating a Sequential-Access Text File 55617.6 Reading Data from a Sequential-Access Text File 56517.7 Case Study: Credit Inquiry Program 56917.8 Serialization 57517.9 Creating a Sequential-Access File Using Object Serialization 57617.10 Reading and Deserializing Data from a Binary File 58017.11 Wrap-Up 582 Chapter 18: Databases and LINQ 58418.1 Introduction 58518.2 Relational Databases 58618.3 A Books Database 58718.4 LINQ to SQL 59018.5 Querying a Database with LINQ 59118.6 Dynamically Binding Query Results 59918.7 Retrieving Data from Multiple Tables with LINQ 60218.8 Creating a Master/Detail View Application 60818.9 Address Book Case Study 61318.10 Tools and Web Resources 61818.11 Wrap-Up 619 Chapter 19: Web App Development with ASP.NET 62019.1 Introduction 62119.2 Web Basics 62219.3 Multitier Application Architecture 62319.4 Your First Web Application 62519.5 Standard Web Controls: Designing a Form 63619.6 Validation Controls 64119.7 Session Tracking 64719.8 Case Study: Database-Driven ASP.NET Guestbook 65719.9 Case Study: ASP.NET AJAX 66419.10 Case Study: Password-Protected Books Database Application 66419.11 Wrap-Up 664 Chapter 20: Searching and Sorting 66620.1 Introduction 66720.2 Searching Algorithms 66720.3 Sorting Algorithms 67720.4 Summary of the Efficiency of Searching and Sorting Algorithms 69120.5 Wrap-Up 691 Chapter 21: Data Structures 69221.1 Introduction 69321.2 Simple-Type structs, Boxing and Unboxing 69321.3 Self-Referential Classes 69421.4 Linked Lists 69521.5 Stacks 70821.6 Queues 71221.7 Trees 71521.8 Wrap-Up 728 Chapter 22: Generics 73022.1 Introduction 73122.2 Motivation for Generic Methods 73222.3 Generic-Method Implementation 73422.4 Type Constraints 73722.5 Overloading Generic Methods 73922.6 Generic Classes 74022.7 Wrap-Up 749 Chapter 23: Collections 75123.1 Introduction 75223.2 Collections Overview 75223.3 Class Array and Enumerators 75523.4 Nongeneric Collections 75823.5 Generic Collections 77023.6 Covariance and Contravariance for Generic Types 77623.7 Wrap-Up 778 Chapter 24: GUI with Windows Presentation Foundation 78024.1 Introduction 78124.2 Windows Presentation Foundation (WPF) 78124.3 XML Basics 78324.4 Structuring Data 78624.5 XML Namespaces 79124.6 Declarative GUI Programming Using XAML 79524.7 Creating a WPF Application in Visual C# Express 79624.8 Laying Out Controls 79824.9 Event Handling 80424.10 Commands and Common Application Tasks 81224.11 WPF GUI Customization 81624.12 Using Styles to Change the Appearance of Controls 81724.13 Customizing Windows 82324.14 Defining a Control's Appearance with Control Templates 82624.15 Data-Driven GUIs with Data Binding 83124.16 Wrap-Up 83724.17 Web Resources 838 Chapter 25: WPF Graphics and Multimedia 83925.1 Introduction 84025.2 Controlling Fonts 84025.3 Basic Shapes 84225.4 Polygons and Polylines 84325.5 Brushes 84725.6 Transforms 85325.7 WPF Customization: A Television GUI 85525.8 Animations 86425.9 (Optional) 3-D Objects and Transforms 86725.10 Speech Synthesis and Speech Recognition 87325.11 Wrap-Up 880 Chapter 26: XML and LINQ to XML 88126.1 Introduction 88226.2 Document Type Definitions (DTDs) 88226.3 W3C XML Schema Documents 88626.4 Extensible Stylesheet Language and XSL Transformations 89326.5 LINQ to XML: Document Object Model (DOM) 90226.6 LINQ to XML Class Hierarchy 90626.7 LINQ to XML: Namespaces and Creating Documents 91526.8 XSLT with Class XslCompiledTransform 91826.9 Wrap-Up 92026.10 Web Resources 920 Chapter 27: Web App Development with ASP.NET: A Deeper Look 92127.1 Introduction 92227.2 Case Study: Password-Protected Books Database Application 92227.3 ASP.NET Ajax 94027.4 Wrap-Up 947 Chapter 28: Web Services 94828.1 Introduction 94928.2 WCF Services Basics 95028.3 Simple Object Access Protocol (SOAP) 95028.4 Representational State Transfer (REST) 95128.5 JavaScript Object Notation (JSON) 95128.6 Publishing and Consuming SOAP-Based WCF Web Services 95228.7 Publishing and Consuming REST-Based XML Web Services 96028.8 Publishing and Consuming REST-Based JSON Web Services 96428.9 Blackjack Web Service: Using Session Tracking in a SOAP-Based WCF Web Service 96828.10 Airline Reservation Web Service: Database Access and Invoking a Service from ASP.NET 98228.11 Equation Generator: Returning User-Defined Types 98628.12 Wrap-Up 99828.13 Deitel Web Services Resource Centers 999 Chapter 29: Silverlight and Rich Internet Applications 100029.1 Introduction 100129.2 Platform Overview 100129.3 Silverlight Runtime and Tools Installation 100229.4 Building a Silverlight WeatherViewer Application 100229.5 Animations and the FlickrViewer 101629.6 Images and Deep Zoom 102529.7 Audio and Video 103829.8 Wrap-Up 1043 Chapter 30: ATM Case Study, Part 1: Object-Oriented Design with the UML 104430.1 Introduction 104530.2 Examining the ATM Requirements Document 104530.3 Identifying the Classes in the ATM Requirements Document 105330.4 Identifying Class Attributes 106030.5 Identifying Objects' States and Activities 106430.6 Identifying Class Operations 106830.7 Identifying Collaboration Among Objects 107530.8 Wrap-Up 1082 Chapter 31: ATM Case Study, Part 2: Implementing an Object-Oriented Design 108731.1 Introduction 108831.2 Starting to Program the Classes of the ATM System 108831.3 Incorporating Inheritance and Polymorphism into the ATM System 109331.4 ATM Case Study Implementation 110031.5 Wrap-Up 1124 Appendix A: Operator Precedence Chart 1127 Appendix B: Simple Types 1129 Appendix C: ASCII Character Set 1131 Appendix D: Number Systems 1132D.1 Introduction 1133D.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers 1136D.3 Converting Octal and Hexadecimal Numbers to Binary Numbers 1137D.4 Converting from Binary, Octal or Hexadecimal to Decimal 1137D.5 Converting from Decimal to Binary, Octal or Hexadecimal 1138D.6 Negative Binary Numbers: Two's Complement Notation 1140 Appendix E: UML 2: Additional Diagram Types 1142E.1 Introduction 1142E.2 Additional Diagram Types 1142 Appendix F: Unicode (R) 1144F.1 Introduction 1145F.2 Unicode Transformation Formats 1146F.3 Characters and Glyphs 1147F.4 Advantages/Disadvantages of Unicode 1147F.5 Using Unicode 1148F.6 Character Ranges 1150 Appendix G: Using the Visual C# 2010 Debugger 1152G.1 Introduction 1153G.2 Breakpoints and the Continue Command 1153G.3 DataTips and Visualizers 1159G.4 The Locals and Watch Windows 1160G.5 Controlling Execution Using the Step Into, Step Over, Step Out and Continue Commands 1163G.6 Other Debugging Features 1166 Index 1170