Home Page Icon
Home Page
Table of Contents for
III. C# and the .NET CLR
Close
III. C# and the .NET CLR
by Jesse Liberty
Programming C#
Programming C#
Preface
About This Book
How the Book Is Organized
Part I
Part II
Part III
Who This Book Is For
C# Versus Visual Basic .NET
C# Versus Java
C# versus C++
Conventions Used in This Book
Support
We’d Like to Hear from You
Acknowledgements
I. The C# Language
1. C# and the .NET Framework
The .NET Platform
The .NET Framework
Compilation and the MSIL
The C# Language
2. Getting Started:"Hello World”
Classes, Objects, and Types
Methods
Comments
Console Applications
Namespaces
The Dot Operator (.)
The using Keyword
Case Sensitivity
The static Keyword
Developing “Hello World”
Editing “Hello World”
Compiling and Running “Hello World”
Using the Visual Studio .NET Debugger
3. C# Language Fundamentals
Types
Working with Built-in Types
Choosing a built-in type
Converting built-in types
Variables and Constants
Definite Assignment
Constants
Enumerations
Strings
Identifiers
Expressions
Whitespace
Statements
Unconditional Branching Statements
Conditional Branching Statements
If...else statements
Nested if statements
Switch statements: an alternative to nested ifs
Switch on string statements
Iteration Statements
The goto statement
The while loop
The do . . . while loop
The for loop
The foreach statement
The continue and break statements
Operators
The Assignment Operator (=)
Mathematical Operators
Simple arithmetical operators (+, -, *, /)
The modulus operator (%) to return remainders
Increment and Decrement Operators
Calculate and reassign operators
The prefix and postfix operators
Relational Operators
Use of Logical Operators with Conditionals
Operator Precedence
The Ternary Operator
Namespaces
Preprocessor Directives
Defining Identifiers
Undefining Identifiers
#if, #elif, #else, and #endif
#region
4. Classes and Objects
Defining Classes
Access Modifiers
Method Arguments
Creating Objects
Constructors
Initializers
Copy Constructors
The this Keyword
Using Static Members
Invoking Static Methods
Using Static Constructors
Using Private Constructors
Using Static Fields
Destroying Objects
The C# Destructor
Finalize Versus Dispose
Implementing the Close Method
The using Statement
Passing Parameters
Passing by Reference
Passing Out Parameters with Definite Assignment
Overloading Methods and Constructors
Encapsulating Data with Properties
The get Accessor
The set Accessor
Readonly Fields
5. Inheritance and Polymorphism
Specialization and Generalization
Inheritance
Implementing Inheritance
Calling Base Class Constructors
Calling Base Class Methods
Controlling Access
Polymorphism
Creating Polymorphic Types
Creating Polymorphic Methods
Versioning with the new and override Keywords
Abstract Classes
Limitations of Abstract
Sealed Class
The Root of all Classes: Object
Boxing and Unboxing Types
Boxing Is Implicit
Unboxing Must Be Explicit
Nesting Classes
6. Operator Overloading
Using the operator Keyword
Supporting Other .NET Languages
Creating Useful Operators
Logical Pairs
The Equals Operator
Conversion Operators
7. Structs
Defining Structs
Creating Structs
Structs as Value Types
Calling the Default Constructor
Creating Structs Without new
8. Interfaces
Implementing an Interface
Implementing More Than One Interface
Extending Interfaces
Combining Interfaces
Accessing Interface Methods
Casting to an Interface
The is Operator
The as Operator
The is Operator Versus the as Operator
Interface Versus Abstract Class
Overriding Interface Implementations
Explicit Interface Implementation
Selectively Exposing Interface Methods
Member Hiding
Accessing Sealed Classes and Value Types
9. Arrays, Indexers, and Collections
Arrays
Declaring Arrays
Understanding Default Values
Accessing Array Elements
The foreach Statement
Initializing Array Elements
The params Keyword
Multidimensional Arrays
Rectangular arrays
Jagged arrays
Array Conversions
System.Array
Indexers
Indexers and Assignment
Indexing on Other Values
Collection Interfaces
The IEnumerable Interface
The ICollection Interface
The IComparer Interface
Array Lists
Implementing IComparable
Implementing IComparer
Queues
Stacks
Dictionaries
Hashtables
IDictionary
The Keys and Values Collections
IDictionaryEnumerator Interface
10. Strings and Regular Expressions
Strings
Creating Strings
The ToString Method
Manipulating Strings
Finding Substrings
Splitting Strings
Manipulating Dynamic Strings
Regular Expressions
Using Regular Expressions: Regex
Using Regex Match Collections
Using Regex Groups
Using CaptureCollection
11. Handling Exceptions
Throwing and Catching Exceptions
The throw Statement
The catch Statement
Taking corrective action
Unwinding the call stack
Creating dedicated catch statements
The finally Statement
Exception Objects
Custom Exceptions
Rethrowing Exceptions
12. Delegates and Events
Delegates
Using Delegates to Specify Methods at Runtime
Static Delegates
Delegates as Properties
Setting Order of Execution with Arrays of Delegates
Multicasting
Events
Publishing and Subscribing
Events and Delegates
Decoupling Publishers from Subscribers
II. Programming with C#
13. Building Windows Applications
Creating a Simple Windows Form
Using Notepad
Using the Visual Studio.Net Designer
Creating a Windows Form Application
Creating the Basic UI Form
Populating the TreeView Controls
TreeNode objects
Recursing through the subdirectories
Getting the files in the directory
Handling TreeView Events
Clicking the source TreeView
Clicking the target TreeView
Handling the Clear button event
Implementing the Copy Button Event
Getting the selected files
Sorting the list of selected files
Handling the Delete Button Event
XML Documentation Comments
Deploying an Application
Deployment Projects
Setup Project
Deployment Locations
Creating a shortcut
Entries in My Documents
Shortcuts in the Start menu
Adding Special Folders
Other View Windows
Making changes to the Registry
Registering file types
Managing the UI during Setup
Other View choices
Building the Setup Project
14. Accessing Data with ADO.NET
Relational Databases and SQL
Tables, Records, and Columns
Normalization
Declarative Referential Integrity
SQL
The ADO.Net Object Model
DataTables and DataColumns
DataRelations
Rows
Data Adapter
DBCommand and DBConnection
The DataAdapter Object
Getting Started with ADO.NET
Using ADO Managed Providers
Working with Data-Bound Controls
Populating a DataGrid
Customizing the DataSet
Combining Data Tables
Changing Database Records
Accessing the Data
Updating a Record
Deleting a Record
Creating New Records
ADO.NET and XML
15. ProgrammingWeb Applications with Web Forms
Understanding Web Forms
Web Form Events
Postback versus non-postback events
State
Web Form Life Cycle
Creating a Web Form
Adding Controls
Data Binding
Setting Initial Properties
Connecting to the Database
Responding to Postback Events
ASP.NET and C#
16. Programming Web Services
SOAP, WSDL, and Discovery
Server-side Support
Client-side Support
Creating the Proxy
III. C# and the .NET CLR
17. Assemblies and Versioning
PE Files
Metadata
Security Boundary
Versioning
Manifests
Modules in the Manifest
Module Manifests
Other Required Assemblies
Multi-Module Assemblies
Benefiting from Multi-Module Assemblies
Building a Multi-Module Assembly
Testing the assembly
Loading the assembly
Private Assemblies
Shared Assemblies
The End of DLL Hell
Versions
Strong Names
The Global Assembly Cache
Building a Shared Assembly
Step 1: Create a strong name
Step 2: Put the shared assembly in the GAC
18. Attributes and Reflection
Attributes
Intrinsic Attributes
Attribute Targets
Applying Attributes
Custom Attributes
Declaring an Attribute
Naming an Attribute
Constructing an Attribute
Using an Attribute
Reflection
Viewing MetaData
Type Discovery
Reflecting on a Type
Finding all type members
Finding type methods
Finding particular type members
Late Binding
Reflection Emit
Dynamic Invocation with InvokeMember( )
Dynamic Invocation with Interfaces
Dynamic Invocation with Reflection Emit
19. Marshaling and Remoting
Application Domains
Creating and Using App Domains
Marshaling Across App Domain Boundaries
Understanding marshaling with proxies
Specifying the marshaling method
Context
Context-Bound and Context-Agile Objects
Marshaling Across Context Boundaries
Remoting
Understanding Server Object Types
Specifying a Server with an Interface
Building a Server
Building the Client
Using SingleCall
Understanding RegisterWellKnownServiceType
Understanding Endpoints
20. Threads and Synchronization
Threads
Starting Threads
Joining Threads
Suspending Threads
Killing Threads
Synchronization
Using Interlocked
Using Locks
Using Monitors
Race Conditions and Deadlocks
Race Conditions
Deadlock
21. Streams
Files and Directories
Working with Directories
Creating a DirectoryInfo Object
Working with Files
Modifying Files
Reading and Writing Data
Binary Files
Buffered Streams
Working with Text Files
Asynchronous I/O
Network I/O
Creating a Network Streaming Server
Creating a Streaming Network Client
Handling Multiple Connections
Aysnchronous Network File Streaming
Web Streams
Serialization
Using a Formatter
Working with Serialization
Serializing the object
Deserializing the object
Handling Transient Data
Isolated Storage
22. Programming .NET and COM
Importing ActiveX Controls
Creating an ActiveX Control
Importing a Control in .NET
Importing a control
Adding a control to the Visual Studio toolbox
Importing COM Components
Coding the COMTestForm program
Importing the COM .DLL to .NET
Importing the Type Library
Importing Manually
Creating a Test Program
Using Late Binding and Reflection
Exporting .NET Components
Creating a Type Library
P/Invoke
Pointers
A. C# Keywords
Index
Colophon
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
Creating the Proxy
Next
Next Chapter
17. Assemblies and Versioning
Part III. C# and the .NET CLR
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