Publisher's Note: Products purchased from Third Party sellers are not guaranteed by the publisher for quality, authenticity, or access to any online entitlements included with the product.
The Most Comprehensive C# Resource Available
With its support for Language-Integrated Query (LINQ), C# 3.0 has revolutionized C# programming, and bestselling author Herb Schildt has updated and expanded his classic programming reference to cover it. Using carefully crafted explanations, insider tips, and hundreds of examples, this book presents in-depth coverage of all aspects of C#, including its keywords, syntax, and core libraries. Of course, details on the new C# 3.0 features, such as LINQ, lambda expressions, implicitly typed variables, and anonymous types are included.
Essential for every C# programmer, this comprehensive guide is written in the clear, crisp, uncompromising style that has made Herb the choice of millions worldwide. Whether you are a novice programmer or a seasoned pro, the answers to all of your C# questions can be found in this definitive resource.
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
Generics
LINQ (Language-Integrated Query)
Lambda expressions
Anonymous types
Extension methods
Implicitly typed variables
I/O, networking, and collections
The preprocessor and much, much more
Author(s): Herbert Schildt
Edition: 3
Publisher: McGraw-Hill Companies
Year: 2008
Language: English
Pages: 912
Contents
Special Thanks
Preface
Part I: The C# Language
1 The Creation of C#
C#’s Family Tree
How C# Relates to the .NET Framework
How the Common Language Runtime Works
Managed vs. Unmanaged Code
2 An Overview of C#
Object-Oriented Programming
A First Simple Program
Handling Syntax Errors
A Small Variation
A Second Simple Program
Another Data Type
Two Control Statements
Using Code Blocks
Semicolons, Positioning, and Indentation
The C# Keywords
Identifiers
The .NET Framework Class Library
3 Data Types, Literals, and Variables
Why Data Types Are Important
C#’s Value Types
Integers
Floating-Point Types
The decimal Type
Characters
The bool Type
Some Output Options
Literals
A Closer Look at Variables
The Scope and Lifetime of Variables
Type Conversion and Casting
Type Conversion in Expressions
4 Operators
Arithmetic Operators
Relational and Logical Operators
The Assignment Operator
The Bitwise Operators
The ? Operator
Spacing and Parentheses
Operator Precedence
5 Program Control Statements
The if Statement
The switch Statement
The for Loop
The while Loop
The do-while Loop
The foreach Loop
Using break to Exit a Loop
Using continue
The goto
6 Introducing Classes and Objects
Class Fundamentals
How Objects Are Created
Reference Variables and Assignment
Methods
Constructors
The new Operator Revisited
Garbage Collection and Destructors
The this Keyword
7 Arrays and Strings
Arrays
Multidimensional Arrays
Jagged Arrays
Assigning Array References
Using the Length Property
Implicitly Typed Arrays
The foreach Loop
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
The Main( ) Method
Recursion
Understanding static
Static Classes
9 Operator Overloading
Operator Overloading Fundamentals
Handling Operations on C# Built-in Types
Overloading the Relational Operators
Overloading true and false
Overloading the Logical Operators
Conversion Operators
Operator Overloading Tips and Restrictions
Another Example of Operator Overloading
10 Indexers and Properties
Indexers
Properties
Use Access Modifiers with Accessors
Using 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
Interfaces
Using Interface References
Interface Properties
Interface Indexers
Interfaces Can Be Inherited
Name Hiding with Interface Inheritance
Explicit Implementations
Choosing Between an Interface and an Abstract Class
The .NET Standard Interfaces
Structures
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
Converting Numeric Strings to Their Internal Representation
15 Delegates, Events, and Lambda Expressions
Delegates
Anonymous Functions
Anonymous Methods
Lambda Expressions
Events
Use Anonymous Methods and Lambda Expressions with Events
.NET Event Guidelines
Applying Events: A Case Study
16 Namespaces, the Preprocessor, and Assemblies
Namespaces
The Preprocessor
Assemblies and the internal Access Modifier
17 Runtime Type ID, Reflection, and Attributes
Runtime Type Identification
Reflection
Using Reflection
Attributes
Three Built-in 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
How Generic Types Are Instantiated
Some Generic Restrictions
Final Thoughts on Generics
19 LINQ
What Is 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
20 Unsafe Code, Pointers, Nullable Types, and Miscellaneous Topics
Unsafe Code
Nullable Types
Partial Types
Partial Methods
Friend Assemblies
Miscellaneous Keywords
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
The IComparable and IComparable Interfaces
The IEquatable Interface
The IConvertible Interface
The ICloneable Interface
IFormatProvider and IFormattable
22 Strings and Formatting
Strings in C#
The String Class
Formatting
Using String.Format( ) and ToString( ) to Format Data
Creating a Custom Numeric Format
Formatting Date and Time
Formatting Enumerations
23 Multithreaded Programming
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
Terminating a Thread
Suspending and Resuming a Thread
Determining a Thread’s State
Using the Main Thread
Multithreading Tips
Starting a Separate Task
24 Collections, Enumerators, and Iterators
Collections Overview
The Non-Generic Collections
Storing Bits with BitArray
The Specialized Collections
The Generic Collections
Storing User-Defined Classes in Collections
Implementing IComparable
Using an IComparer
Accessing a Collection via an Enumerator
Implementing IEnumerable and IEnumerator
Using Iterators
Collection Initializers
25 Networking Through the Internet Using System.Net
The System.Net Members
Uniform Resource Identifiers
Internet Access Fundamentals
Handling Network Errors
The Uri Class
Accessing Additional HTTP Response Information
MiniCrawler: A Case Study
Using WebClient
26 Use System.Windows.Forms to Create Form-Based Windows Applications
A Brief History of Windows Programming
Two Ways to Write a Form-Based Windows Application
How Windows Interacts with the User
Windows Forms
A Skeletal Form-Based Windows Program
Adding a Button
Handling Messages
Using a Message Box
Adding a Menu
A: Documentation Comment Quick Reference
The XML Comment Tags
Compiling Documentation Comments
An XML Documentation Example
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z