Introduction | p. 1 |
The Significance of .NET and C# | p. 1 |
So What is .NET? | p. 3 |
Advantages of .NET | p. 3 |
Where C# Fits In | p. 4 |
What You Need to Write and Run C# Code | p. 6 |
What This Book Covers | p. 6 |
The C# Language | p. 7 |
.NET Programming | p. 7 |
Data Access | p. 7 |
Internet Programming | p. 7 |
Components | p. 7 |
Advanced .NET Programming | p. 7 |
Conventions | p. 7 |
Technical Support | p. 8 |
p2p.wrox.com | p. 9 |
C# and .NET Architecture | p. 11 |
The Relationship of C# to .NET | p. 12 |
The Common Language Runtime | p. 12 |
Advantages of Managed Code | p. 12 |
A Closer Look at Intermediate Language | p. 16 |
Support for Object Orientation and Interfaces | p. 16 |
Distinct Value and Reference Types | p. 17 |
Strong Data Typing | p. 18 |
Error Handling Via Exceptions | p. 24 |
Use of Attributes | p. 25 |
Assemblies | p. 25 |
Private Assemblies | p. 26 |
Shared Assemblies | p. 27 |
Reflection | p. 27 |
.NET Framework Classes | p. 27 |
Namespaces | p. 29 |
Creating .NET Applications Using C# | p. 29 |
Creating ASP .NET Applications | p. 29 |
Creating Windows Forms | p. 32 |
Windows Services | p. 32 |
The Role of C# in .NET Enterprise Architecture | p. 32 |
Summary | p. 34 |
C# Basics | p. 37 |
Before We Start | p. 38 |
Our First C# Program | p. 38 |
A Closer Look | p. 39 |
Variables | p. 42 |
Initialization of Variables | p. 42 |
Variable Scope | p. 44 |
Constants | p. 46 |
Predefined Data Types | p. 47 |
Value Types and Reference Types | p. 47 |
CTS Types | p. 49 |
Predefined Value Types | p. 49 |
Predefined Reference Types | p. 53 |
Flow Control | p. 55 |
Conditional Statements | p. 55 |
Loops | p. 60 |
Jump Statements | p. 63 |
Program Structure | p. 64 |
Classes | p. 65 |
Structs | p. 67 |
Methods | p. 68 |
Declaring Methods | p. 68 |
Invoking Methods | p. 69 |
Passing Parameters to Methods | p. 71 |
Arrays | p. 74 |
Array Syntax | p. 74 |
Operators | p. 78 |
Operator Shortcuts | p. 80 |
The Ternary Operator | p. 81 |
checked and unchecked | p. 82 |
is | p. 83 |
sizeof | p. 83 |
typeof | p. 83 |
Operator Precedence | p. 83 |
Type Safety | p. 84 |
Type Conversions | p. 84 |
Boxing and Unboxing | p. 88 |
Enumerations | p. 89 |
Namespaces | p. 91 |
The using Statement | p. 92 |
Namespace Aliases | p. 93 |
The Main() Method | p. 94 |
Multiple Main() Methods | p. 94 |
Passing Arguments to Main() | p. 95 |
More on Compiling C# Files | p. 96 |
Console I/O | p. 98 |
Using Comments | p. 100 |
XML Documentation | p. 101 |
Identifiers and Keywords | p. 104 |
Summary | p. 105 |
Object-Oriented C# | p. 109 |
Classes and Inheritance | p. 110 |
Single Implementation Inheritance | p. 110 |
Method Overloading | p. 111 |
Method Overriding and Hiding | p. 112 |
Calling Base Versions of Functions | p. 114 |
Abstract Classes and Functions | p. 115 |
Sealed Classes and Methods | p. 115 |
Access Modifiers | p. 116 |
Properties | p. 117 |
Read-Only and Write-Only Properties | p. 118 |
Access Modifiers | p. 118 |
Virtual and Abstract Properties | p. 119 |
Inlining | p. 119 |
The Object Class | p. 119 |
The ToString() method | p. 121 |
Interfaces | p. 122 |
Construction and Disposal | p. 129 |
Constructors | p. 130 |
Cleaning up: Destructors and Dispose() | p. 140 |
Using the IDisposable Interface | p. 144 |
Implementing Destructors and Dispose() | p. 145 |
readonly Fields | p. 146 |
Structs | p. 148 |
Structs Are Value Types | p. 149 |
Structs and Inheritance | p. 150 |
Constructors for Structs | p. 151 |
Operator Overloading | p. 151 |
How Operators Work | p. 153 |
Indexers | p. 162 |
Summary | p. 166 |
Advanced C# Topics | p. 169 |
Errors and Exception Handling | p. 170 |
Exception Classes | p. 170 |
Catching Exceptions | p. 172 |
User-Defined Exception Classes | p. 182 |
User-Defined Casts | p. 190 |
Implementing User-Defined Casts | p. 192 |
Multiple Casting | p. 199 |
Delegates | p. 203 |
Using Delegates in C# | p. 204 |
SimpleDelegate Example | p. 207 |
BubbleSorter Example | p. 209 |
Multicast Delegates | p. 212 |
Events | p. 214 |
The Consumer's View of Events | p. 215 |
Events Example: Console Notifications | p. 217 |
The C# Preprocessor Directives | p. 224 |
#define and #undef | p. 224 |
#if, #elif, #else, and #endif | p. 225 |
#warning and #error | p. 226 |
#region and #endregion | p. 226 |
#line | p. 227 |
Attributes | p. 227 |
Memory Management Under the Hood | p. 231 |
Unsafe Code | p. 237 |
Pointers | p. 237 |
Using Pointers to Optimize Performance | p. 252 |
Summary | p. 256 |
C# and the Base Classes | p. 259 |
System.Object | p. 260 |
Comparing Reference Objects for Equality | p. 262 |
Comparing Value Types for Equality | p. 264 |
String Handling | p. 264 |
System.String | p. 265 |
Building Strings | p. 266 |
Format Strings | p. 270 |
Regular Expressions | p. 276 |
Introduction to Regular Expressions | p. 277 |
The RegularExpressionsPlayaround Example | p. 278 |
Displaying Results | p. 280 |
Matches, Groups, and Captures | p. 282 |
Groups of Objects | p. 284 |
Array Lists | p. 285 |
Collections | p. 287 |
Dictionaries | p. 291 |
Custom Attributes | p. 301 |
Writing Custom Attributes | p. 302 |
The WhatsNewAttributes Example | p. 306 |
Reflection | p. 309 |
The System Type Class | p. 309 |
The TypeView Example | p. 312 |
The Assembly Class | p. 314 |
Completing the WhatsNewAttributes Sample | p. 316 |
Threading | p. 320 |
Applications with Multiple Threads | p. 321 |
Manipulating Threads | p. 322 |
The ThreadPlayaround Sample | p. 325 |
Thread Priorities | p. 328 |
Synchronization | p. 329 |
Summary | p. 334 |
Programming in the .NET Environment | p. 337 |
Visual Studio .NET | p. 338 |
Creating a Project | p. 341 |
Solutions and Projects | p. 346 |
Windows Application Code | p. 350 |
Reading in Visual Studio 6 Projects | p. 350 |
Exploring and Coding a Project | p. 351 |
Building a Project | p. 363 |
Debugging | p. 367 |
Other .NET Tools | p. 370 |
WinCV | p. 371 |
.NET Usage Guidelines | p. 372 |
Naming Conventions | p. 373 |
Use of Properties and Methods | p. 377 |
Use of Fields | p. 377 |
Summary | p. 378 |
Windows Applications | p. 381 |
Windows Applications in .NET | p. 382 |
Windows Forms | p. 384 |
Windows Forms Without Visual Studio .NET | p. 384 |
Windows Forms Using Visual Studio .NET | p. 389 |
Menus | p. 395 |
Dialogs | p. 401 |
Visual Inheritance | p. 411 |
Windows Controls | p. 415 |
Dynamic Controls | p. 416 |
Custom Controls | p. 421 |
The UserControl Class | p. 421 |
Summary | p. 435 |
Assemblies | p. 437 |
What are Assemblies? | p. 437 |
The Answer to DLL Hell | p. 438 |
Features of Assemblies | p. 439 |
Application Domains and Assemblies | p. 440 |
Assembly Structure | p. 443 |
Assembly Manifests | p. 444 |
Namespaces, Assemblies, and Components | p. 444 |
Private and Shared Assemblies | p. 445 |
Viewing Assemblies | p. 445 |
Building Assemblies | p. 447 |
Cross-Language Support | p. 451 |
The CTS and the CLS | p. 452 |
Language Independence in Action | p. 453 |
CLS Requirements | p. 462 |
Adding Resources to Assemblies | p. 464 |
Creating Resource Files | p. 465 |
Using Resource Files | p. 466 |
Internationalization and Resources | p. 469 |
Localization Example Using Visual Studio .NET | p. 475 |
Global Assembly Cache | p. 485 |
Native Image Generator | p. 486 |
Global Assembly Cache Viewer | p. 486 |
Creating Shared Assemblies | p. 488 |
Shared Assembly Names | p. 488 |
Creating a Shared Assembly | p. 491 |
Configuration | p. 495 |
Configuration Categories | p. 495 |
Versioning | p. 496 |
Configuring Directories | p. 505 |
Deployment | p. 508 |
Deployment of DLLs | p. 508 |
Creating a Merge Module | p. 508 |
Summary | p. 510 |
Data Access with .NET | p. 513 |
ADO.NET Overview | p. 514 |
Namespaces | p. 514 |
Shared Classes | p. 515 |
Database Specific Classes | p. 515 |
Using Database Connections | p. 516 |
Using Connections Efficiently | p. 517 |
Transactions | p. 520 |
Commands | p. 521 |
Executing Commands | p. 522 |
Calling Stored Procedures | p. 526 |
Quick Data Access: The Data Reader | p. 529 |
Managing Data and Relationships: The DataSet | p. 532 |
Data Tables | p. 533 |
Data Relationships | p. 540 |
Data Constraints | p. 542 |
XML Schemas | p. 544 |
Generating Code with XSD | p. 545 |
Populating a DataSet | p. 550 |
Populating a DataSet Using a DataAdapter | p. 550 |
Populating a DataSet from XML | p. 552 |
Persisting DataSet Changes | p. 552 |
Updating with Data Adapters | p. 553 |
Writing XML Output | p. 555 |
Working with ADO.NET | p. 557 |
Tiered Development | p. 557 |
Key Generation with SQL Server | p. 558 |
Naming Conventions | p. 561 |
Performance | p. 562 |
Summary | p. 563 |
Viewing .NET Data | p. 567 |
The DataGrid Control | p. 568 |
Displaying Tabular Data | p. 568 |
Data Sources | p. 570 |
DataGrid Class Hierarchy | p. 578 |
Data Binding | p. 582 |
Simple Binding | p. 582 |
Data Binding Objects | p. 583 |
Visual Studio and Data Access | p. 589 |
Creating a Connection | p. 589 |
Selecting Data | p. 592 |
Generating a DataSet | p. 594 |
Updating the Data Source | p. 595 |
Building a Schema | p. 597 |
Other Common Requirements | p. 603 |
Summary | p. 611 |
Manipulating XML | p. 615 |
XML Standards Support in .NET | p. 616 |
Introducing the System.Xml Namespace | p. 616 |
Using MSXML in .NET | p. 617 |
Using System.Xml Classes | p. 621 |
Reading and Writing Streamed XML | p. 621 |
Using the XmlTextReader Class | p. 622 |
Using the XmlValidatingReader Class | p. 626 |
Using the XmlTextWriter Class | p. 629 |
Using the DOM in .NET | p. 631 |
Using the XmlDocument Class | p. 633 |
Using XPath and XSLT in .NET | p. 637 |
The System.XPath Namespace | p. 638 |
The System.Xml.Xsl Namespace | p. 642 |
XML and ADO.NET | p. 647 |
Converting ADO.NET Data to XML | p. 647 |
Converting XML to ADO.NET Data | p. 655 |
Reading and Writing a DiffGram | p. 658 |
Serializing Objects in XML | p. 661 |
Serialization Without Sourcecode Access | p. 669 |
Summary | p. 671 |
File and Registry Operations | p. 673 |
Managing the File System | p. 674 |
.NET Classes that Represent Files and Folders | p. 675 |
The Path Class | p. 677 |
Example: A File Browser | p. 678 |
Moving, Copying, and Deleting Files | p. 683 |
Example: FilePropertiesAndMovement | p. 684 |
Reading and Writing to Files | p. 688 |
Streams | p. 688 |
Reading and Writing to Binary Files | p. 690 |
Reading and Writing to Text Files | p. 696 |
Reading and Writing to the Registry | p. 703 |
The Registry | p. 703 |
The .NET Registry Classes | p. 706 |
Example: SelfPlacingWindow | p. 708 |
Summary | p. 715 |
Working with the Active Directory | p. 717 |
Architecture of the Active Directory | p. 718 |
Features | p. 718 |
Active Directory Concepts | p. 719 |
Characteristics of Active Directory Data | p. 723 |
Schema | p. 723 |
Administration Tools for the Active Directory | p. 724 |
Active Directory Users and Computers | p. 725 |
ADSI Edit | p. 726 |
ADSI Viewer | p. 727 |
Active Directory Service Interfaces (ADSI) | p. 729 |
Programming the Active Directory | p. 729 |
Classes in System.DirectoryServices | p. 730 |
Binding | p. 730 |
Getting Directory Entries | p. 735 |
Object Collections | p. 737 |
Cache | p. 738 |
Creating New Objects | p. 739 |
Updating Directory Entries | p. 740 |
Accessing Native ADSI Objects | p. 741 |
Searching in the Active Directory | p. 742 |
Searching for User Objects | p. 746 |
User Interface | p. 746 |
Get the Schema Naming Context | p. 747 |
Get the Property Names of the User Class | p. 748 |
Search For User Objects | p. 749 |
Summary | p. 751 |
ASP.NET Pages | p. 753 |
ASP.NET Introduction | p. 754 |
State Management in ASP.NET | p. 755 |
ASP.NET Web Forms | p. 755 |
ASP.NET Server Controls | p. 760 |
ADO.NET and Data Binding | p. 773 |
Updating the Event Booking Application | p. 774 |
More on Data Binding | p. 782 |
Application Configuration | p. 788 |
Summary | p. 789 |
Web Services | p. 791 |
SOAP | p. 792 |
WSDL | p. 793 |
Web Services | p. 795 |
Exposing Web Services | p. 795 |
Consuming Web Services | p. 798 |
Extending the Meeting Room Booker Example | p. 801 |
The Meeting Room Booking Web Service | p. 802 |
The Meeting Room Booker Client | p. 804 |
Exchanging Data using SOAP Headers | p. 807 |
Summary | p. 811 |
User Controls and Custom Controls | p. 815 |
User Controls | p. 816 |
A Simple User Control | p. 816 |
Custom Controls | p. 823 |
Custom Control Project Configuration | p. 824 |
Basic Custom Controls | p. 829 |
Creating a Composite Custom Control | p. 835 |
A Straw Poll Control | p. 837 |
The Candidate Controls | p. 839 |
The StrawPoll Control Builder | p. 840 |
Straw Poll Style | p. 842 |
The Straw Poll Control | p. 842 |
Summary | p. 849 |
COM Interoperability | p. 851 |
A Quick Tour of COM | p. 852 |
How COM Works | p. 852 |
Using COM Components in .NET | p. 853 |
Binding to COM Components | p. 853 |
Runtime Callable Wrappers | p. 853 |
Using a C++ COM Component | p. 857 |
Filling a DataSet with a Recordset | p. 860 |
Late Binding to COM Components | p. 862 |
Releasing COM Objects | p. 863 |
Using ActiveX Controls in .NET | p. 864 |
Using .NET Components in COM | p. 866 |
COM-Callable Wrappers | p. 866 |
The C# Factorial Component | p. 867 |
Early Binding to .NET Components | p. 869 |
Platform Invocation Services | p. 870 |
Accessing Unmanaged Code | p. 871 |
Summary | p. 872 |
COM+ Services | p. 875 |
COM+ Services in Perspective | p. 875 |
The Component Services Snap-In | p. 876 |
Features of COM+ Services | p. 877 |
Transactions | p. 878 |
Just-In-Time Activation (JIT) | p. 879 |
Security | p. 880 |
Events | p. 880 |
Object Pooling | p. 881 |
Message Queuing | p. 882 |
Component Load Balancing | p. 882 |
Using COM+ Services with .NET Assemblies | p. 883 |
Using Transactions with .NET Assemblies | p. 885 |
Using Object Pooling with .NET Assemblies | p. 891 |
Using JIT Activation with .NET Assemblies | p. 893 |
Summary | p. 894 |
Graphics with GDI+ | p. 897 |
Understanding Drawing Principles | p. 898 |
GDI and GDI+ | p. 898 |
Drawing Shapes | p. 900 |
Painting Shapes Using OnPaint() | p. 903 |
Using the Clipping Region | p. 904 |
Measuring Coordinates and Areas | p. 906 |
Point and PointF | p. 906 |
Size and SizeF | p. 908 |
Rectangle and RectangleF | p. 909 |
Region | p. 910 |
A Note about Debugging | p. 911 |
Drawing Scrollable Windows | p. 912 |
Colors | p. 919 |
Red-Green-Blue (RGB) Values | p. 919 |
The Named Colors | p. 920 |
Graphics Display Modes and the Safety Palette | p. 920 |
The Safety Palette | p. 921 |
Pens and Brushes | p. 921 |
Brushes | p. 922 |
Pens | p. 923 |
Drawing Shapes and Lines | p. 923 |
Displaying Images | p. 926 |
Issues When Manipulating Images | p. 928 |
Drawing Text | p. 929 |
Simple Text Example | p. 930 |
Fonts and Font Families | p. 931 |
Example: Enumerating Font Families | p. 933 |
Editing a Text Document: The CapsEditor Sample | p. 935 |
The Invalidate() Method | p. 939 |
Calculating Item Sizes and Document Size | p. 941 |
OnPaint() | p. 942 |
Coordinate Transforms | p. 943 |
Responding to User Input | p. 945 |
Printing | p. 948 |
Summary | p. 954 |
Accessing the Internet | p. 957 |
The WebClient Class | p. 958 |
Downloading Files | p. 958 |
Basic Web Client Example | p. 958 |
Uploading Files | p. 960 |
WebRequest and WebResponse Classes | p. 960 |
Displaying Output as an HTML Page | p. 963 |
The Web Request and Web Response Hierarchy | p. 965 |
Utility Classes | p. 967 |
URIs | p. 967 |
IP Addresses and DNS Names | p. 969 |
Lower-Level Protocols | p. 971 |
Lower-Level Classes | p. 972 |
Summary | p. 978 |
Distributed Applications with .NET Remoting | p. 981 |
What is .NET Remoting? | p. 982 |
Web Services Anywhere | p. 983 |
CLR Object Remoting | p. 983 |
.NET Remoting Overview | p. 983 |
Contexts | p. 986 |
Activation | p. 987 |
Attributes and Properties | p. 988 |
Communication between Contexts | p. 988 |
Remote Objects, Clients, and Servers | p. 988 |
Remote Objects | p. 989 |
A Simple Server | p. 990 |
A Simple Client | p. 991 |
.NET Remoting Architecture | p. 992 |
Channels | p. 993 |
Formatters | p. 996 |
ChannelServices and RemotingConfiguration | p. 997 |
Object Activation | p. 998 |
Message Sinks | p. 1002 |
Passing Objects in Remote Methods | p. 1003 |
Lifetime Management | p. 1007 |
Miscellaneous .NET Remoting Features | p. 1010 |
Configuration Files | p. 1010 |
Hosting Applications | p. 1018 |
Classes, Interfaces, and SoapSuds | p. 1019 |
Tracking Services | p. 1022 |
Asynchronous Remoting | p. 1024 |
Remoting and Events | p. 1025 |
Call Contexts | p. 1031 |
Summary | p. 1033 |
Windows Services | p. 1035 |
What is a Windows Service? | p. 1036 |
Windows Services Architecture | p. 1037 |
Service Program | p. 1037 |
Service Control Program | p. 1039 |
Service Configuration Program | p. 1039 |
System.ServiceProcess Namespace | p. 1040 |
Creating a Windows Service | p. 1040 |
A Class Library Using Sockets | p. 1041 |
TcpClient Example | p. 1044 |
Windows Service Project | p. 1046 |
Threading and Services | p. 1051 |
Service Installation | p. 1052 |
Installation Program | p. 1052 |
Monitoring and Controlling the Service | p. 1058 |
MMC Computer Management | p. 1058 |
net.exe | p. 1059 |
sc.exe | p. 1060 |
Visual Studio .NET Server Explorer | p. 1061 |
ServiceController Class | p. 1061 |
Troubleshooting | p. 1067 |
Interactive Services | p. 1068 |
Event Logging | p. 1068 |
Performance Monitoring | p. 1074 |
Windows 2000 Service Features | p. 1080 |
Network Binding Changes and Power Events | p. 1080 |
Recovery | p. 1081 |
COM+ Applications as Services | p. 1082 |
Summary | p. 1082 |
.NET Security | p. 1085 |
Code Access Security | p. 1086 |
Code Groups | p. 1087 |
Code Access Permissions and Permissions Sets | p. 1093 |
Policy Levels: Machine, User, and Enterprise | p. 1098 |
Support for Security in the Framework | p. 1100 |
Demanding Permissions | p. 1100 |
Requesting Permissions | p. 1103 |
Implicit Permission | p. 1106 |
Denying Permissions | p. 1107 |
Asserting Permissions | p. 1108 |
Creating Code Access Permissions | p. 1110 |
Declarative Security | p. 1110 |
Role-Based Security | p. 1111 |
The Principal | p. 1112 |
Windows Principal | p. 1113 |
Roles | p. 1114 |
Declarative Role-Based Security | p. 1114 |
Managing Security Policy | p. 1115 |
The Security Configuration File | p. 1116 |
Managing Code Groups and Permissions | p. 1120 |
Turning Security On and Off | p. 1121 |
Resetting Security Policy | p. 1121 |
Creating a Code Group | p. 1121 |
Deleting a Code Group | p. 1122 |
Changing a Code Group's Permissions | p. 1122 |
Creating and Applying Permissions Sets | p. 1123 |
Distributing Code Using a Strong Name | p. 1126 |
Distributing Code Using Certificates | p. 1128 |
Managing Zones | p. 1136 |
Summary | p. 1138 |
Principles of Object-Oriented Programming | p. 1141 |
A Note for VB 6 Programmers | p. 1142 |
What is an Object? | p. 1142 |
Objects in Programming | p. 1143 |
Class Members | p. 1143 |
Defining a Class | p. 1144 |
Instantiating and Using Objects | p. 1145 |
Using Static Members | p. 1147 |
A Note About Reference Types | p. 1151 |
Overloading Methods | p. 1152 |
Properties | p. 1154 |
Introducing Inheritance | p. 1156 |
Using Inheritance in C# | p. 1157 |
Class Hierarchies and Class Design | p. 1163 |
Polymorphism and Virtual Members | p. 1166 |
Method Hiding | p. 1169 |
Abstract Functions and Base Classes | p. 1170 |
Sealed Classes and Methods | p. 1173 |
Interfaces | p. 1174 |
Construction and Disposal | p. 1175 |
Creating Constructors | p. 1176 |
Summary | p. 1179 |
C# Compilation Options | p. 1181 |
Using the C# Compiler | p. 1181 |
Input and Output Files | p. 1183 |
Compiling Different Project Types | p. 1183 |
Response Files | p. 1183 |
Compiler Options | p. 1184 |
Index | p. 1191 |
Table of Contents provided by Ingram. All Rights Reserved. |