Home Page Icon
Home Page
Table of Contents for
About the Technical Reviewer
Close
About the Technical Reviewer
by Daniel Solis
Illustrated C# 2008
Copyright
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
1. C# and the .NET Framework
1.1. Before .NET
1.1.1. Windows Programming in the Late 1990s
1.1.2. Goals for the Next-Generation Platform
1.2. Enter Microsoft .NET
1.2.1. Components of the .NET Framework
1.2.2. An Improved Programming Environment
1.2.2.1. Object-Oriented Development Environment
1.2.2.2. Automatic Garbage Collection
1.2.2.3. Interoperability
1.2.2.4. No COM Required
1.2.2.5. Simplified Deployment
1.2.2.6. Type Safety
1.2.2.7. The Base Class Library
1.3. Compiling to the Common Intermediate Language (CIL)
1.4. Compiling to Native Code and Execution
1.4.1. Overview of Compilation and Execution
1.5. The Common Language Runtime (CLR)
1.6. The Common Language Infrastructure (CLI)
1.6.1. Important Parts of the CLI
1.6.1.1. Common Type System (CTS)
1.6.1.2. Common Language Specification (CLS)
1.7. Review of the Acronyms
2. Overview of C# Programming
2.1. A Simple C# Program
2.2. More About SimpleProgram
2.3. Identifiers and Keywords
2.4. Naming Conventions
2.5. Keywords
2.6. Main: The Starting Point of a Program
2.7. Whitespace
2.8. Statements
2.9. Simple Statements
2.10. Blocks
2.11. Text Output from a Program
2.12. Write
2.13. WriteLine
2.14. The Format String
2.15. Multiple Markers and Values
2.16. Comments: Annotating the Code
2.17. More About Comments
2.18. Documentation Comments
2.19. Summary of Comment Types
3. Types, Storage, and Variables
3.1. A C# Program Is a Set of Type Declarations
3.2. A Type Is a Template
3.3. Instantiating a Type
3.4. Data Members and Function Members
3.4.1. Types of Members
3.5. Predefined Types
3.5.1. More About the Predefined Types
3.6. User-Defined Types
3.7. The Stack and the Heap
3.7.1. The Stack
3.7.1.1. Facts About Stacks
3.7.2. The Heap
3.8. Value Types and Reference Types
3.8.1. Storing Members of a Reference Type Object
3.8.2. Categorizing the C# Types
3.9. Variables
3.9.1. Variable Declarations
3.9.1.1. Variable Initializers
3.9.1.2. Automatic Initialization
3.9.2. Multiple-Variable Declarations
3.9.3. Using the Value of a Variable
4. Classes: The Basics
4.1. Overview of Classes
4.1.1. A Class Is an Active Data Structure
4.2. Programs and Classes: A Quick Example
4.3. Declaring a Class
4.4. Class Members
4.4.1. Fields
4.4.1.1. Explicit and Implicit Field Initialization
4.4.1.2. Declarations with Multiple Fields
4.4.2. Methods
4.5. Creating Variables and Instances of a Class
4.6. Allocating Memory for the Data
4.6.1. Combining the Steps
4.7. Instance Members
4.8. Access Modifiers
4.8.1. Private and Public Access
4.8.1.1. Depicting Public and Private Access
4.8.1.2. Example of Member Access
4.9. Accessing Members from Inside the Class
4.10. Accessing Members from Outside the Class
4.11. Putting It All Together
5. Methods
5.1. The Structure of a Method
5.1.1. Code Execution in the Method Body
5.2. Local Variables
5.2.1. Type Inference and the var Keyword
5.2.2. Local Variables Inside Nested Blocks
5.3. Local Constants
5.3.1. Flow of Control
5.4. Method Invocations
5.5. Return Values
5.5.1. The Return Statement and Void Methods
5.6. Parameters
5.6.1. Formal Parameters
5.6.2. Actual Parameters
5.6.2.1. An Example of Methods with Input Parameters
5.7. Value Parameters
5.8. Reference Parameters
5.9. Output Parameters
5.10. Parameter Arrays
5.10.1. Method Invocation
5.10.1.1. Expanded Form
5.10.2. Arrays As Actual Parameters
5.11. Summary of Parameter Types
5.12. Stack Frames
5.13. Recursion
5.14. Method Overloading
6. More About Classes
6.1. Class Members
6.1.1. Order of Member Modifiers
6.2. Instance Class Members
6.3. Static Fields
6.4. Accessing Static Members from Outside the Class
6.4.1. Example of a Static Field
6.4.2. Lifetimes of Static Members
6.5. Static Function Members
6.6. Other Static Class Member Types
6.7. Member Constants
6.7.1. Constants Are Like Statics
6.8. Properties
6.8.1. Property Declarations and Accessors
6.8.2. A Property Example
6.8.3. Using a Property
6.8.4. Properties and Associated Fields
6.8.5. Performing Other Calculations
6.8.6. Read-Only and Write-Only Properties
6.8.7. An Example of a Computed, Read-Only Property
6.8.8. Example of Properties and Databases
6.8.9. Automatically Implemented Properties
6.8.10. Static Properties
6.9. Instance Constructors
6.9.1. Constructors with Parameters
6.9.2. Default Constructors
6.10. Static Constructors
6.10.1. Example of a Static Constructor
6.10.2. Accessibility of Constructors
6.11. Object Initializers
6.12. Destructors
6.12.1. Calling the Destructor
6.12.2. The Standard Dispose Pattern
6.13. Comparing Constructors and Destructors
6.14. The readonly Modifier
6.15. The this Keyword
6.16. Indexers
6.16.1. What Is an Indexer?
6.16.2. Indexers and Properties
6.16.3. Declaring an Indexer
6.16.4. The set Accessor
6.16.5. The get Accessor
6.16.6. More About Indexers
6.16.7. Declaring the Indexer for the Employee Example
6.16.8. Another Indexer Example
6.16.9. Indexer Overloading
6.17. Access Modifiers on Accessors
6.18. Partial Classes and Partial Types
6.18.1. Partial Methods
7. Classes and Inheritance
7.1. Class Inheritance
7.2. Accessing the Inherited Members
7.2.1. All Classes Are Derived from Class object
7.3. Hiding Members of a Base Class
7.4. Base Access
7.5. Using References to a Base Class
7.5.1. Virtual and Override Methods
7.5.2. Overriding a Method Marked override
7.5.2.1. Case 1: Declaring Print with override
7.5.2.2. Case 2: Declaring Print with new
7.6. Constructor Execution
7.6.1. Constructor Initializers
7.6.2. Class Access Modifiers
7.7. Inheritance Between Assemblies
7.8. Member Access Modifiers
7.8.1. Regions Accessing a Member
7.8.2. Public Member Accessibility
7.8.3. Private Member Accessibility
7.8.4. Protected Member Accessibility
7.8.5. Internal Member Accessibility
7.8.6. Protected Internal Member Accessibility
7.8.7. Summary of Member Access Modifiers
7.9. Abstract Members
7.10. Abstract Classes
7.10.1. Example of an Abstract Class and an Abstract Method
7.11. Sealed Classes
7.12. Static Classes
7.13. Extension Methods
7.14. External Methods
8. Expressions and Operators
8.1. Expressions
8.2. Literals
8.3. Integer Literals
8.3.1. Real Literals
8.4. Character Literals
8.5. String Literals
8.6. Order of Evaluation
8.6.1. Precedence
8.6.2. Associativity
8.7. Simple Arithmetic Operators
8.8. The Remainder Operator
8.9. Relational and Equality Comparison Operators
8.9.1. Comparison and Equality Operations
8.10. Increment and Decrement Operators
8.11. Conditional Logical Operators
8.12. Logical Operators
8.13. Shift Operators
8.14. Assignment Operators
8.14.1. Compound Assignment
8.15. The Conditional Operator
8.16. Unary Arithmetic Operators
8.17. User-Defined Type Conversions
8.17.1. Explicit Conversion and the Cast Operator
8.18. Operator Overloading
8.18.1. Restrictions on Operator Overloading
8.18.2. Example of Operator Overloading
8.19. The typeof Operator
9. Statements
9.1. What Are Statements?
9.2. Expression Statements
9.3. Flow-of-Control Statements
9.4. The if Statement
9.5. The if . . . else Statement
9.6. The switch Statement
9.6.1. A Switch Example
9.6.2. More on the switch Statement
9.6.3. Switch Labels
9.7. The while Loop
9.8. The do Loop
9.9. The for Loop
9.9.1. The Scope of Variables in a for Statement
9.9.2. Multiple Expressions in the Initializer and Iteration Expression
9.10. Jump Statements
9.11. The break Statement
9.12. The continue Statement
9.13. Labeled Statements
9.13.1. Labels
9.13.2. The Scope of Labeled Statements
9.14. The goto Statement
9.14.1. The goto Statement Inside a switch Statement
9.15. The using Statement
9.15.1. Packaging Use of the Resource
9.15.2. Example of the using Statement
9.15.3. Multiple Resources and Nesting
9.15.4. Another Form of the using Statement
9.16. Other Statements
10. Namespaces and Assemblies
10.1. Referencing Other Assemblies
10.1.1. The mscorlib Library
10.2. Namespaces
10.2.1. Namespace Names
10.2.2. More About Namespaces
10.2.3. Namespaces Spread Across Files
10.2.4. Nesting Namespaces
10.3. The using Directives
10.3.1. The using Namespace Directive
10.3.2. The using Alias Directive
10.4. The Structure of an Assembly
10.5. The Identity of an Assembly
10.6. Strongly Named Assemblies
10.6.1. Creating a Strongly Named Assembly
10.7. Private Deployment of an Assembly
10.8. Shared Assemblies and the GAC
10.8.1. Installing Assemblies into the GAC
10.8.2. Side-by-Side Execution in the GAC
10.9. Configuration Files
10.10. Delayed Signing
11. Exceptions
11.1. What Are Exceptions?
11.2. The try Statement
11.2.1. Handling the Exception
11.3. The Exception Classes
11.4. The catch Clause
11.5. Examples Using Specific catch Clauses
11.6. The catch Clauses Section
11.7. The finally Block
11.8. Finding a Handler for an Exception
11.9. Searching Further
11.9.1. General Algorithm
11.9.2. Example of Searching Down the Call Stack
11.10. Throwing Exceptions
11.11. Throwing Without an Exception Object
12. Structs
12.1. What Are Structs?
12.2. Structs Are Value Types
12.3. Assigning to a Struct
12.4. Constructors and Destructors
12.4.1. Instance Constructors
12.4.2. Static Constructors
12.4.3. Summary of Constructors and Destructors
12.5. Field Initializers Are Not Allowed
12.6. Structs Are Sealed
12.7. Boxing and Unboxing
12.8. Structs As Return Values and Parameters
12.9. Additional Information About Structs
13. Enumerations
13.1. Enumerations
13.1.1. Setting the Underlying Type and Explicit Values
13.1.2. Implicit Member Numbering
13.2. Bit Flags
13.2.1. The Flags Attribute
13.2.2. Example Using Bit Flags
13.3. More About Enums
14. Arrays
14.1. Arrays
14.1.1. Definitions
14.1.2. Important Details
14.2. Types of Arrays
14.3. An Array As an Object
14.4. One-Dimensional and Rectangular Arrays
14.4.1. Declaring a One-Dimensional Array or a Rectangular Array
14.5. Instantiating a One-Dimensional or Rectangular Array
14.6. Accessing Array Elements
14.7. Initializing an Array
14.7.1. Explicit Initialization of One-Dimensional Arrays
14.7.2. Explicit Initialization of Rectangular Arrays
14.7.3. Syntax Points for Initializing Rectangular Arrays
14.7.4. Shortcut Syntax
14.7.5. Implicitly Typed Arrays
14.7.6. Putting It All Together
14.8. Jagged Arrays
14.8.1. Declaring a Jagged Array
14.8.2. Shortcut Instantiation
14.8.3. Instantiating a Jagged Array
14.8.4. Sub-Arrays in Jagged Arrays
14.9. Comparing Rectangular and Jagged Arrays
14.10. The foreach Statement
14.10.1. The Iteration Variable Is Read-Only
14.10.2. The foreach Statement with Multidimensional Arrays
14.10.2.1. Example with a Rectangular Array
14.10.2.2. Example with a Jagged Array
14.11. Array Covariance
14.12. Useful Inherited Array Members
14.12.1. The Clone Method
14.13. Comparing Array Types
15. Delegates
15.1. What Is a Delegate?
15.1.1. Methods in the Invocation List
15.2. Declaring the Delegate Type
15.3. Creating the Delegate Object
15.4. Assigning Delegates
15.5. Combining Delegates
15.6. Adding Methods to Delegates
15.7. Removing Methods from a Delegate
15.8. Invoking a Delegate
15.9. Delegate Example
15.10. Invoking Delegates with Return Values
15.11. Invoking Delegates with Reference Parameters
15.12. Anonymous Methods
15.12.1. Using Anonymous Methods
15.12.2. Syntax of Anonymous Methods
15.12.2.1. Return Type
15.12.2.2. Parameters
15.12.2.3. params Parameters
15.12.3. Scope of Variables and Parameters
15.12.3.1. Outer Variables
15.12.3.2. Extension of Captured Variable's Lifetime
15.13. Lambda Expressions
16. Events
16.1. Events Are Like Delegates
16.1.1. An Event Has a Private Delegate
16.2. Overview of Source Code Components
16.3. Declaring an Event
16.3.1. An Event Is a Member
16.3.2. The Delegate Type and EventHandler
16.4. Raising an Event
16.5. Subscribing to an Event
16.5.1. Removing Event Handlers
16.6. Standard Event Usage
16.6.1. Using the EventArgs Class
16.6.2. Passing Data by Extending EventArgs
16.6.3. Using the Custom Delegate
16.7. The MyTimerClass Code
16.8. Event Accessors
17. Interfaces
17.1. What Is an Interface?
17.1.1. Example Using the IComparable Interface
17.2. Declaring an Interface
17.3. Implementing an Interface
17.3.1. Example with a Simple Interface
17.4. An Interface Is a Reference Type
17.5. Using the as Operator with Interfaces
17.6. Implementing Multiple Interfaces
17.7. Implementing Interfaces with Duplicate Members
17.8. References to Multiple Interfaces
17.9. An Inherited Member As an Implementation
17.10. Explicit Interface Member Implementations
17.10.1. Accessing Explicit Interface Member Implementations
17.11. Interfaces Can Inherit Interfaces
17.11.1. Example of Different Classes Implementing an Interface
18. Conversions
18.1. What Are Conversions?
18.2. Implicit Conversions
18.3. Explicit Conversions and Casting
18.3.1. Casting
18.4. Types of Conversions
18.5. Numeric Conversions
18.5.1. Implicit Numeric Conversions
18.5.2. Overflow Checking Context
18.5.2.1. The checked and unchecked Operators
18.5.2.2. The checked and unchecked Statements
18.5.3. Explicit Numeric Conversions
18.5.3.1. Integral to Integral
18.5.3.2. float or double to Integral
18.5.3.3. decimal to Integral
18.5.3.4. double to float
18.5.3.5. float or double to decimal
18.5.3.6. decimal to float or double
18.6. Reference Conversions
18.6.1. Implicit Reference Conversions
18.6.2. Explicit Reference Conversions
18.6.3. Valid Explicit Reference Conversions
18.7. Boxing Conversions
18.7.1. Boxing Creates a Copy
18.7.1.1. The Boxing Conversions
18.8. Unboxing Conversions
18.8.1. The Unboxing Conversions
18.9. User-Defined Conversions
18.9.1. Constraints on User-Defined Conversions
18.9.2. Example of a User-Defined Conversion
18.9.3. Evaluating User-Defined Conversions
18.9.4. Example of a Multi-Step User-Defined Conversion
18.10. The is Operator
18.11. The as Operator
19. Generics
19.1. What Are Generics?
19.1.1. A Stack Example
19.2. Generics in C#
19.2.1. Continuing with the Stack Example
19.3. Generic Classes
19.4. Declaring a Generic Class
19.5. Creating a Constructed Type
19.6. Creating Variables and Instances
19.6.1. The Stack Example Using Generics
19.6.2. Comparing the Generic and Non-Generic Stack
19.7. Constraints on Type Parameters
19.7.1. Where Clauses
19.7.2. Constraint Types and Order
19.8. Generic Structs
19.9. Generic Interfaces
19.9.1. An Example Using Generic Interfaces
19.9.2. Generic Interface Implementations Must Be Unique
19.10. Generic Delegates
19.10.1. Another Generic Delegate Example
19.11. Generic Methods
19.11.1. Declaring a Generic Method
19.11.2. Invoking a Generic Method
19.11.2.1. Inferring Types
19.11.3. Example of a Generic Method
19.12. Extension Methods with Generic Classes
20. Enumerators and Iterators
20.1. Enumerators and Enumerable Types
20.1.1. Using the foreach Statement
20.1.2. Types of Enumerators
20.2. Using the IEnumerator Interface
20.2.1. Declaring an IEnumerator Enumerator
20.3. The IEnumerable Interface
20.3.1. Example Using IEnumerable and IEnumerator
20.4. The Non-Interface Enumerator
20.5. The Generic Enumeration Interfaces
20.6. The IEnumerator<T> Interface
20.7. The IEnumerable<T> Interface
20.8. Iterators
20.8.1. Iterator Blocks
20.8.2. Using an Iterator to Create an Enumerator
20.8.3. Using an Iterator to Create an Enumerable
20.9. Common Iterator Patterns
20.10. Producing Enumerables and Enumerators
20.11. Producing Multiple Enumerables
20.12. Producing Multiple Enumerators
20.13. Behind the Scenes with Iterators
21. Introduction to LINQ
21.1. What Is LINQ?
21.2. LINQ Providers
21.2.1. Anonymous Types
21.3. Query Syntax and Method Syntax
21.4. Query Variables
21.5. The Structure of Query Expressions
21.5.1. The from Clause
21.5.2. The join Clause
21.5.3. What Is a Join?
21.5.4. The from . . . let . . . where Section in the Query Body
21.5.4.1. The from Clause
21.5.4.2. The let Clause
21.5.4.3. The where Clause
21.5.5. The orderby Clause
21.5.6. The select . . . group Clause
21.5.7. Anonymous Types in Queries
21.5.8. The group Clause
21.5.9. Query Continuation
21.6. The Standard Query Operators
21.6.1. Query Expressions and the Standard Query Operators
21.6.2. Signatures of the Standard Query Operators
21.6.3. Delegates As Parameters
21.6.4. The LINQ Predefined Delegate Types
21.6.5. Example Using a Delegate Parameter
21.6.6. Example Using a Lambda Expression Parameter
21.7. LINQ to XML
21.7.1. Markup Languages
21.7.2. XML Basics
21.7.3. The XML Classes
21.7.3.1. Creating, Saving, Loading, and Displaying an XML Document
21.7.3.2. Creating an XML Tree
21.7.4. Using Values from the XML Tree
21.7.4.1. Adding Nodes and Manipulating XML
21.7.5. Working with XML Attributes
21.7.6. Other Types of Nodes
21.7.6.1. XComment
21.7.6.2. XDeclaration
21.7.6.3. XProcessingInstruction
21.7.7. Using LINQ Queries with LINQ to XML
22. Introduction to Asynchronous Programming
22.1. Processes, Threads, and Asynchronous Programming
22.1.1. Multithreading Considerations
22.1.2. The Complexity of Multithreading
22.2. Asynchronous Programming Patterns
22.3. BeginInvoke and EndInvoke
22.3.1. The Wait-Until-Done Pattern
22.3.2. The AsyncResult Class
22.3.3. The Polling Pattern
22.3.4. The Callback Pattern
22.3.4.1. The Callback Method
22.3.4.2. Calling EndInvoke Inside the Callback Method
22.4. Timers
23. Preprocessor Directives
23.1. What Are Preprocessor Directives?
23.2. General Rules
23.3. The #define and #undef Directives
23.4. Conditional Compilation
23.5. The Conditional Compilation Constructs
23.6. Diagnostic Directives
23.7. Line Number Directives
23.8. Region Directives
23.9. The #pragma warning Directive
24. Reflection and Attributes
24.1. Metadata and Reflection
24.2. The Type Class
24.3. Getting a Type Object
24.4. What Is an Attribute?
24.5. Applying an Attribute
24.6. Predefined, Reserved Attributes
24.6.1. The Obsolete Attribute
24.6.2. The Conditional Attribute
24.6.2.1. Example of the Conditional Attribute
24.6.3. Predefined Attributes
24.7. More About Applying Attributes
24.7.1. Multiple Attributes
24.7.2. Other Types of Targets
24.7.3. Global Attributes
24.8. Custom Attributes
24.8.1. Declaring a Custom Attribute
24.8.2. Using Attribute Constructors
24.8.3. Specifying the Constructor
24.8.4. Using the Constructor
24.8.5. Positional and Named Parameters in Constructors
24.8.6. Restricting the Usage of an Attribute
24.8.6.1. The Constructor for AttributeUsage
24.8.7. Suggested Practices for Custom Attributes
24.9. Accessing an Attribute
24.9.1. Using the IsDefined Method
24.9.2. Using the GetCustomAttributes Method
25. Other Topics
25.1. Overview
25.2. Strings
25.2.1. Using Class StringBuilder
25.2.2. Formatting Numeric Strings
25.2.2.1. The Alignment Specifier
25.2.2.2. The Format Component
25.2.2.3. Standard Numeric Format Specifiers
25.3. Parsing Strings to Data Values
25.4. Nullable Types
25.4.1. Creating a Nullable Type
25.4.2. Assigning to a Nullable Type
25.4.2.1. Using Operators and the Null Coalescing Operator
25.4.3. Using Nullable User-Defined Types
25.4.3.1. Nullable<T>
25.5. Method Main
25.5.1. Accessibility of Main
25.6. Documentation Comments
25.6.1. Inserting Documentation Comments
25.6.2. Using Other XML Tags
25.7. Nested Types
25.7.1. Example of a Nested Class
25.7.2. Visibility and Nested Types
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
About the Author
Next
Next Chapter
Acknowledgments
About the Technical Reviewer
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset