Synopses & Reviews
With dynamic typing and many other new features, C# 4.0 has already piqued the interest of .NET developers worldwide. This bestselling tutorial for beginning to intermediate programmers teaches you how to use the new version of the C# language to build web, desktop, and rich Internet applications with the .NET 4.0 Framework.
In this sixth edition, .NET experts Ian Griffiths and Matthew Adams cover the latest enhancements to the language, as well as the fundamentals of both C# and .NET. The book explains concurrent programming with C# 4.0, and teaches you how to use C# with .NET tools such as the Entity Framework for easier data access, and the Silverlight platform for browser-based RIA development.
With Programming C# 4.0, you will:
- Learn C# and .NET programming with a comprehensive tutorial that also serves as a useful reference
- Find many more useful code examples than in previous editions
- Learn basic language and framework features, from classes to assemblies
- Get details on new C# 4.0 features and capabilities, from optional and named arguments to dynamic and concurrent programming
- Learn about LINQ, anonymous delegates, and lambda expressions
Programming C# 4.0 provides a clear and concise way for programmers to learn C# 4.0 quickly and thoroughly. No prior .NET experience is required for you to get started.
Synopsis
With its support for dynamic programming, C# 4.0 continues to evolve as a versatile language on its own. But when C# is used with .NET Framework 4, the combination is incredibly powerful. This bestselling tutorial shows you how to build web, desktop, and rich Internet applications using C# 4.0 with .NET's database capabilities, UI framework (WPF), extensive communication services (WCF), and more.
In this sixth edition, .NET experts Ian Griffiths, Matthew Adams, and Jesse Liberty cover the latest enhancements to C#, as well as the fundamentals of both the language and framework. You'll learn concurrent programming with C# 4.0, and how to use .NET tools such as the Entity Framework for easier data access, and the Silverlight platform for browser-based RIA development.
- Learn C# fundamentals, such as variables, flow control, loops, and methods
- Build complex programs with object-oriented and functional programming techniques
- Process large collections of data with the native query features in LINQ
- Communicate across networks with Windows Communication Foundation (WCF)
- Learn the advantages of C# 4.0's dynamic language features
- Build interactive Windows applications with Windows Presentation Foundation (WPF)
- Create rich web applications with Silverlight and ASP.NET
Synopsis
A top-selling tutorial since the release of C# and the .NET Framework, "Programming C# 4.0" is a thorough revision of this classic text. This tutorial for beginning to intermediate programmers teaches readers how to use Microsoft's C# 4.0 language to build web, desktop and rich internet applications with the .NET 4.0 Framework. The new edition covers the latest enhancements to the C# language, while more deeply explaining and demonstrating its legacy syntax.
About the Author
Matthew is the Director of Development at Digital Healthcare Ltd. The last three years have kept him fully occupied in the development of a C#/.NET-based distributed imaging platform for healthcare applications. Before that, he studied Natural Sciences at Cambridge University, worked on banking and imaging applications in North America, became a fully-paid-up C++ junkie, and was the lead architect on software solutions for drug-discovery for a large US corporation. He thinks that .NET is a major philosophical stride forward for the computer industry: so much so that he almost doesn't miss his first love - generics - in C#. He has written articles and given papers on the subject to both technical and non-technical audiences, and looks forward to the day when he doesn't have to answer the question 'So, what is .NET?' any more!
Jesse Liberty, "Silverlight Geek", is a senior program manager for Microsoft Silverlight in the Silverlight Development Division where he is responsible for the creation of tutorials, videos and other content to facilitate the learning and use of Silverlight.
Even before joining Microsoft, Jesse is well known in the industry in part because of his many bestselling books, including O'Reilly Media's Programming .NET 3.5, Programming C# 3.0, Learning ASP.NET with AJAX and the soon to be published Programming Silverlight. He has over two decades experience writing software, consulting and training, with stints as at AT&T as a Distinguished Software Engineer and at Citibank as a Vice President in the Information Division.
Table of Contents
Preface; How This Book Is Organized; Who This Book Is For; What You Need to Use This Book; Conventions Used in This Book; Using Code Examples; Safari® Books Online; Acknowledgments; Chapter 1: Introducing C#; 1.1 Why C#? Why .NET?; 1.2 The .NET Framework Class Library; 1.3 Language Style; 1.4 C# 4.0, .NET 4, and Visual Studio 2010; 1.5 Summary; Chapter 2: Basic Programming Techniques; 2.1 Getting Started; 2.2 Namespaces and Types; 2.3 Projects and Solutions; 2.4 Comments, Regions, and Readability; 2.5 Variables; 2.6 Expressions and Statements; 2.7 Flow Control with Selection Statements; 2.8 Iteration Statements; 2.9 Methods; 2.10 Summary; Chapter 3: Abstracting Ideas with Classes and Structs; 3.1 Divide and Conquer; 3.2 Defining Classes; 3.3 Related Constants with enum; 3.4 Value Types and Reference Types; 3.5 Too Many Constructors, Mr. Mozart; 3.6 Overloading; 3.7 Object Initializers; 3.8 Defining Methods; 3.9 Static Fields and Properties; 3.10 Summary; Chapter 4: Extensibility and Polymorphism; 4.1 Association Through Composition and Aggregation; 4.2 Inheritance and Polymorphism; 4.3 Replacing Methods in Derived Classes; 4.4 Inheritance and Protection; 4.5 Calling Base Class Methods; 4.6 Thus Far and No Farther: sealed; 4.7 Requiring Overrides with abstract; 4.8 All Types Are Derived from Object; 4.9 C# Does Not Support Multiple Inheritance of Implementation; 4.10 C# Supports Multiple Inheritance of Interface; 4.11 Deriving Interfaces from Other Interfaces; 4.12 The Last Resort: Checking Types at Runtime; 4.13 Summary; Chapter 5: Composability and Extensibility with Delegates; 5.1 Functional Composition with delegate; 5.2 Generic Actions with Action
; 5.3 Generic Predicates with Predicate; 5.4 Using Anonymous Methods; 5.5 Creating Delegates with Lambda Expressions; 5.6 Delegates in Properties; 5.7 Generic Delegates for Functions; 5.8 Notifying Clients with Events; 5.9 Summary; Chapter 6: Dealing with Errors; 6.1 When and How to Fail; 6.2 Returning Error Values; 6.3 Exceptions; 6.4 Summary; Chapter 7: Arrays and Lists; 7.1 Arrays; 7.2 List; 7.3 Collections and Polymorphism; 7.4 Summary; Chapter 8: LINQ; 8.1 Query Expressions; 8.2 LINQ Concepts and Techniques; 8.3 LINQ Operators; 8.4 Summary; Chapter 9: Collection Classes; 9.1 Dictionaries; 9.2 HashSet and SortedSet; 9.3 Queues; 9.4 Linked Lists; 9.5 Stacks; 9.6 Summary; Chapter 10: Strings; 10.1 What Is a String?; 10.2 The String and Char Types; 10.3 Literal Strings and Chars; 10.4 Formatting Data for Output; 10.5 Culture Sensitivity; 10.6 Accessing Characters by Index; 10.7 Strings Are Immutable; 10.8 Getting a Range of Characters; 10.9 Composing Strings; 10.10 Manipulating Text; 10.11 Finding and Replacing Content; 10.12 All Sorts of "Empty" Strings; 10.13 Trimming Whitespace; 10.14 Checking Character Types; 10.15 Encoding Characters; 10.16 Summary; Chapter 11: Files and Streams; 11.1 Inspecting Directories and Files; 11.2 Examining Directories; 11.3 Manipulating File Paths; 11.4 Examining File Information; 11.5 Creating Temporary Files; 11.6 Deleting Files; 11.7 Well-Known Folders; 11.8 Concatenating Path Elements Safely; 11.9 Creating and Securing Directory Hierarchies; 11.10 Deleting a Directory; 11.11 Writing Text Files; 11.12 When Files Go Bad: Dealing with Exceptions; 11.13 Reading Files into Memory; 11.14 Streams; 11.15 Reading, Writing, and Locking Files; 11.16 FileStream Constructors; 11.17 Asynchronous File Operations; 11.18 Isolated Storage; 11.19 Streams That Aren't Files; 11.20 Summary; Chapter 12: XML; 12.1 XML Basics (A Quick Review); 12.2 X Stands for eXtensible; 12.3 Creating XML Documents; 12.4 Searching in XML with LINQ; 12.5 XML Serialization; 12.6 Summary; Chapter 13: Networking; 13.1 Choosing a Networking Technology; 13.2 WCF; 13.3 HTTP; 13.4 Sockets; 13.5 Other Networking Features; 13.6 Summary; Chapter 14: Databases; 14.1 The .NET Data Access Landscape; 14.2 The Entity Data Model; 14.3 Queries; 14.4 Object Context; 14.5 WCF Data Services; 14.6 Summary; Chapter 15: Assemblies; 15.1 .NET Components: Assemblies; 15.2 Naming; 15.3 Loading; 15.4 Summary; Chapter 16: Threads and Asynchronous Code; 16.1 Threads; 16.2 Synchronization Primitives; 16.3 Asynchronous Programming; 16.4 The Task Parallel Library; 16.5 Data Parallelism; 16.6 Summary; Chapter 17: Attributes and Reflection; 17.1 Attributes; 17.2 Reflection; 17.3 Summary; Chapter 18: Dynamic; 18.1 Static Versus Dynamic; 18.2 The dynamic Type; 18.3 dynamic in Noninterop Scenarios?; 18.4 Summary; Chapter 19: Interop with COM and Win32; 19.1 Importing ActiveX Controls; 19.2 Interop Assemblies; 19.3 64-bit Versus 32-bit; 19.4 P/Invoke; 19.5 Pointers; 19.6 C# 4.0 Interop Syntax Enhancements; 19.7 Summary; Chapter 20: WPF and Silverlight; 20.1 Xaml and Code Behind; 20.2 Elements and Controls; 20.3 Control Templates; 20.4 Data Binding; 20.5 Summary; Chapter 21: Programming ASP.NET Applications; 21.1 Web Forms Fundamentals; 21.2 Creating a Web Application; 21.3 Data Binding; 21.4 Summary; Chapter 22: Windows Forms; 22.1 Creating the Application; 22.2 Controls; 22.3 Data Binding; 22.4 Event Handling; 22.5 Summary; Colophon;