Book description
The Definitive Guide to C#
“From using LINQ to covariance and from string formatting to optional arguments, Herb’s update covers all you need to know about using real-world C# 4.0.” —Michael Howard, Microsoft CorporationBestselling author Herb Schildt has updated and expanded his classic programming reference to cover C# 4.0--the latest release of this powerful, feature-rich language. Using carefully crafted explanations, insider tips, and hundreds of examples, C# 4.0: The Complete Reference offers in-depth details on all aspects of C#, including keywords, syntax, and core libraries. New C# 4.0 features, such as named and optional arguments, the dynamic type, expanded covariance and contravariance capabilities, and support for parallel programming with the Task Parallel Library (TPL) and PLINQ are also discussed.
Perfect for beginners and professional C# programmers alike, this expert resource is written in the clear, crisp, uncompromising style that has made Herb the choice of millions worldwide. Begin mastering C# 4.0 today with help from this authoritative volume!
Coverage includes:
- Data types and operators
- Control statements
- Classes and objects
- Constructors, destructors, and methods
- Interfaces, arrays, enumerations, and structures
- Method and operator overloading
- Inheritance and virtual methods
- Reflection and runtime type ID
- Exception handling
- Delegates, properties, events, and indexers
- Attributes
- Multithreading and the Task Parallel Library
- Generics
- LINQ and PLINQ
- Lambda expressions
- Anonymous types
- Extension methods
- Named and optional arguments
- Implicitly typed variables
- I/O, networking, and collections
- The preprocessor and much, much more
Table of contents
- Cover Page
- C# 4.0: The Complete Reference
- Copyright Page
- Contents
- Special Thanks
- Preface
-
Part I The C# Language
- 1 The Creation of C#
- 2 An Overview of C#
- 3 Data Types, Literals, and Variables
- 4 Operators
- 5 Program Control Statements
- 6 Introducing Classes and Objects
- 7 Arrays and Strings
-
8 A Closer Look at Methods and Classes
- Controlling Access to Class Members
- Pass References to Methods
- Use ref and out Parameters
- Use a Variable Number of Arguments
- Return Objects
- Method Overloading
- Overload Constructors
- Object Initializers
- Optional Arguments
- Named Arguments
- The Main( ) Method
- Recursion
- Understanding static
- Static Classes
- 9 Operator Overloading
- 10 Indexers and Properties
-
11 Inheritance
- Inheritance Basics
- Member Access and Inheritance
- Constructors and Inheritance
- Inheritance and Name Hiding
- Creating a Multilevel Hierarchy
- When Are Constructors Called?
- Base Class References and Derived Objects
- Virtual Methods and Overriding
- Using Abstract Classes
- Using sealed to Prevent Inheritance
- The object Class
- 12 Interfaces, Structures, and Enumerations
-
13 Exception Handling
- The System.Exception Class
- Exception-Handling Fundamentals
- The Consequences of an Uncaught Exception
- Exceptions Let You Handle Errors Gracefully
- Using Multiple catch Clauses
- Catching All Exceptions
- Nesting try Blocks
- Throwing an Exception
- Using finally
- A Closer Look at the Exception Class
- Deriving Exception Classes
- Catching Derived Class Exceptions
- Using checked and unchecked
-
14 Using I/O
- C#’s I/O Is Built Upon Streams
- The Stream Classes
- Console I/O
- FileStream and Byte-Oriented File I/O
- Character-Based File I/O
- Redirecting the Standard Streams
- Reading and Writing Binary Data
- Random Access Files
- Using MemoryStream
- Using StringReader and StringWriter
- The File Class
- Converting Numeric Strings to Their Internal Representation
- 15 Delegates, Events, and Lambda Expressions
- 16 Namespaces, the Preprocessor, and Assemblies
- 17 Runtime Type ID, Reflection, and Attributes
-
18 Generics
- What Are Generics?
- A Simple Generics Example
- A Generic Class with Two Type Parameters
- The General Form of a Generic Class
- Constrained Types
- Creating a Default Value of a Type Parameter
- Generic Structures
- Creating a Generic Method
- Generic Delegates
- Generic Interfaces
- Comparing Instances of a Type Parameter
- Generic Class Hierarchies
- Overriding Virtual Methods in a Generic Class
- Overloading Methods That Use Type Parameters
- Covariance and Contravariance in Generic Type Parameters
- How Generic Types Are Instantiated
- Some Generic Restrictions
- Final Thoughts on Generics
-
19 LINQ
- LINQ Fundamentals
- Filter Values with where
- Sort Results with orderby
- A Closer Look at select
- Use Nested from Clauses
- Group Results with group
- Use into to Create a Continuation
- Use let to Create a Variable in a Query
- Join Two Sequences with join
- Anonymous Types
- Create a Group Join
- The Query Methods
- Deferred vs. Immediate Query Execution
- Expression Trees
- Extension Methods
- PLINQ
- 20 Unsafe Code, Pointers, Nullable Types, Dynamic Types, and Miscellaneous Topics
-
Part II Exploring the C# Library
-
21 Exploring the System Namespace
- The Members of System
- The Math Class
- The .NET Structures Corresponding to the Built-in Value Types
- The Array Class
- BitConverter
- Generating Random Numbers with Random
- Memory Management and the GC Class
- Object
- Tuple
- The IComparable and IComparable<T> Interfaces
- The IEquatable<T> Interface
- The IConvertible Interface
- The ICloneable Interface
- IFormatProvider and IFormattable
- IObservable<T> and IObserver<T>
- 22 Strings and Formatting
-
23 Multithreaded Programming, Part One
- Multithreading Fundamentals
- The Thread Class
- Determining When a Thread Ends
- Passing an Argument to a Thread
- The IsBackground Property
- Thread Priorities
- Synchronization
- Thread Communication Using Wait( ), Pulse( ), and PulseAll( )
- Deadlock and Race Conditions
- Using MethodImplAttribute
- Using a Mutex and a Semaphore
- Using Events
- The Interlocked Class
- Synchronization Classes Added by .NET 4.0
- Terminating a Thread Via Abort( )
- Suspending and Resuming a Thread
- Determining a Thread’s State
- Using the Main Thread
- Additional Multithreading Features Added by .NET 4.0
- Multithreading Tips
- Starting a Separate Task
-
24 Multithreading, Part Two: Exploring the Task Parallel Library and PLINQ
- Two Approaches to Parallel Programming
- The Task Class
- Using Wait Methods
- Using TaskFactory to Start a Task
- Use a Lambda Expression as a Task
- Create a Task Continuation
- Returning a Value from a Task
- Cancelling a Task and Using AggregateException
- Some Other Task Features
- The Parallel Class
- Exploring PLINQ
-
25 Collections, Enumerators, and Iterators
- Collections Overview
- The Non-Generic Collections
- Storing Bits with BitArray
- The Specialized Collections
- The Generic Collections
- The Concurrent Collections
- Storing User-Defined Classes in Collections
- Implementing IComparable
- Using an IComparer
- Using StringComparer
- Accessing a Collection via an Enumerator
- Implementing IEnumerable and IEnumerator
- Using Iterators
- Collection Initializers
- 26 Networking Through the Internet Using System.Net
-
21 Exploring the System Namespace
- A Documentation Comment Quick Reference
- Index
Product information
- Title: C# 4.0 The Complete Reference
- Author(s):
- Release date: April 2010
- Publisher(s): McGraw-Hill
- ISBN: 9780071741170
You might also like
book
C# 6.0 and the .NET 4.6 Framework, Seventh Edition
This new 7th edition of Pro C# 6.0 and the .NET 4.6 Platform has been completely …
video
C# 8 and .NET Core 3.1 Recipes - Second Edition
C# is a multi-paradigm programming language providing support for software engineering principles such as strong type …
book
C# 10 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library
Discover what's new in C# and .NET for Windows programming. This book is a condensed code …
book
Programming in C#: Exam 70-483 (MCSD) Guide
Acquire necessary skills in preparing for Microsoft certification and enhance your software development career by learning …