Professional C#

Free Download

Authors:

Edition: 3rd ed

Series: Programmer to Programmer

ISBN: 9780764557590, 0764557599

Size: 20 MB (21136367 bytes)

Pages: 1395/1395

File format:

Language:

Publishing Year:

Category:

Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen9780764557590, 0764557599

C# is designed to work with .NET to provide a new framework for programming on the Windows platform. This comprehensive reference prepares you to program in C#, while at the same time providing the necessary background in how the .NET architecture works. This book is for experienced developers who are already familiar with C++, Visual Basic, or J++. No prior knowledge of C# is required.

Table of contents :
Professional C#……Page 1
About the Authors……Page 6
Credits……Page 8
Contents……Page 10
The Significance of .NET and C#……Page 28
Advantages of .NET……Page 29
What’s New in the .NET Framework 1.1……Page 30
New Data Providers……Page 31
Visual Studio .NET 2003 Enhancements……Page 32
Where C# Fits In……Page 33
Part V: Web Programming……Page 35
Conventions……Page 36
Errata……Page 37
p2p.wrox.com……Page 38
Part I: The C# Language……Page 40
.NET Architecture……Page 42
Advantages of Managed Code……Page 43
A Closer Look at Intermediate Language……Page 46
Support for Object Orientation and Interfaces……Page 47
Strong Data Typing……Page 48
Error Handling with Exceptions……Page 55
Assemblies……Page 56
Private Assemblies……Page 57
.NET Framework Classes……Page 58
Creating ASP.NET Applications……Page 60
The Role of C# in the .NET Enterprise Architecture……Page 63
Summary……Page 65
C# Basics……Page 68
The Code……Page 69
A Closer Look……Page 70
Initialization of Variables……Page 73
Variable Scope……Page 74
Constants……Page 77
Value Types and Reference Types……Page 78
CTS Types……Page 79
Predefined Value Types……Page 80
Predefined Reference Types……Page 83
Conditional Statements……Page 86
Loops……Page 90
Jump Statements……Page 93
Enumerations……Page 94
Arrays……Page 96
Namespaces……Page 97
The using Statement……Page 98
Namespace Aliases……Page 99
Multiple Main() Methods……Page 100
Passing Arguments to Main()……Page 101
More on Compiling C# Files……Page 102
Console I/O……Page 104
Internal Comments Within the Source Files……Page 106
XML Documentation……Page 107
#define and #undef……Page 109
#if, #elif, #else, and #endif……Page 110
#line……Page 111
Rules for Identifiers……Page 112
Usage Conventions……Page 113
Summary……Page 120
Objects and Types……Page 122
Classes and Structs……Page 123
Function Members……Page 124
readonly Fields……Page 138
Structs……Page 140
Structs Are Value Types……Page 141
Constructors for Structs……Page 142
System.Object Methods……Page 143
The ToString() Method……Page 144
Summary……Page 146
Implementation Versus Interface Inheritance……Page 148
Structs and Classes……Page 149
Implementation Inheritance……Page 150
Virtual Methods……Page 151
Hiding Methods……Page 152
Calling Base Versions of Functions……Page 153
Sealed Classes and Methods……Page 154
Constructors of Derived Classes……Page 155
Visibility Modifiers……Page 161
Interfaces……Page 162
Defining and Implementing Interfaces……Page 164
Derived Interfaces……Page 167
Summary……Page 169
Operators……Page 170
Operator Shortcuts……Page 172
The checked and unchecked Operators……Page 173
The is Operator……Page 174
The typeof Operator……Page 175
Type Safety……Page 176
Type Conversions……Page 177
Boxing and Unboxing……Page 180
The ReferenceEquals() Method……Page 181
Comparing Value Types for Equality……Page 182
Operator Overloading……Page 183
How Operators Work……Page 184
Operator Overloading Example: The Vector Struct……Page 185
Which Operators Can You Overload?……Page 192
User-Defined Casts……Page 193
Implementing User-Defined Casts……Page 194
Multiple Casting……Page 200
Summary……Page 204
Delegates……Page 206
Using Delegates in C#……Page 208
SimpleDelegate Example……Page 211
BubbleSorter Example……Page 213
Multicast Delegates……Page 216
Events……Page 218
The Receiver’s View of Events……Page 219
Generating Events……Page 221
Summary……Page 225
Memory Management under the Hood……Page 226
Value Data Types……Page 227
Reference Data Types……Page 229
Garbage Collection……Page 231
Destructors……Page 232
The IDisposable Interface……Page 234
Implementing IDisposable and a Destructor……Page 235
Unsafe Code……Page 236
Pointers……Page 237
Pointer Example: PointerPlayaround……Page 246
Using Pointers to Optimize Performance……Page 251
Summary……Page 255
Strings and Regular Expressions……Page 256
System.String……Page 257
Building Strings……Page 258
Format Strings……Page 262
Introduction to Regular Expressions……Page 268
The RegularExpressionsPlayaround Example……Page 269
Displaying Results……Page 272
Matches, Groups, and Captures……Page 273
Summary……Page 276
Examining Groups of Objects……Page 278
Array Lists……Page 279
Collections……Page 280
Dictionaries……Page 284
Summary……Page 295
Reflection……Page 296
Writing Custom Attributes……Page 297
Custom Attribute Example: WhatsNewAttributes……Page 301
Reflection……Page 304
The System.Type Class……Page 305
The TypeView Example……Page 307
The Assembly Class……Page 310
Completing the WhatsNewAttributes Sample……Page 311
Summary……Page 315
Looking into Errors and Exception Handling……Page 316
Exception Classes……Page 317
Catching Exceptions……Page 319
User-Defined Exception Classes……Page 329
Summary……Page 336
Part II: The .NET Enviroment……Page 338
Working with Visual Studio .NET 2003……Page 340
Creating a Project……Page 343
Solutions and Projects……Page 350
Reading in Visual Studio 6 Projects……Page 353
Exploring and Coding a Project……Page 354
Building a Project……Page 365
Debugging……Page 370
The ASP.NET Web Matrix Project……Page 373
WinCV……Page 374
Summary……Page 376
What Are Assemblies?……Page 378
The Answer to DLL Hell……Page 379
Application Domains and Assemblies……Page 380
Assembly Structure……Page 383
Namespaces, Assemblies, and Components……Page 385
Viewing Assemblies……Page 386
Building Assemblies……Page 387
The CTS and the CLS……Page 392
Language Independence in Action……Page 393
CLS Requirements……Page 403
Native Image Generator……Page 405
Global Assembly Cache Viewer……Page 406
Global Assembly Cache Utility (gacutil.exe)……Page 407
Shared Assembly Names……Page 408
Creating a Shared Assembly……Page 410
Configuration Categories……Page 415
Versioning……Page 416
Configuring Directories……Page 426
Summary……Page 429
.NET Security……Page 430
Code Access Security……Page 431
Code Groups……Page 432
Code Access Permissions and Permissions Sets……Page 438
Policy Levels: Machine, User, and Enterprise……Page 442
Support for Security in the Framework……Page 444
Demanding Permissions……Page 445
Requesting Permissions……Page 446
Implicit Permission……Page 449
Denying Permissions……Page 450
Asserting Permissions……Page 451
Declarative Security……Page 453
The Principal……Page 454
Windows Principal……Page 455
Roles……Page 456
Declarative Role-Based Security……Page 457
The Security Configuration File……Page 458
Creating a Code Group……Page 462
Changing a Code Group’s Permissions……Page 463
Creating and Applying Permissions Sets……Page 464
Distributing Code Using a Strong Name……Page 466
Distributing Code Using Certificates……Page 468
Managing Zones……Page 474
Summary……Page 476
Threading……Page 478
Manipulating Threads……Page 480
The ThreadPlayaround Sample……Page 483
Thread Priorities……Page 487
Synchronization……Page 488
Summary……Page 492
Distributed Applications with .NET Remoting……Page 494
Application Types and Protocols……Page 495
.NET Remoting Overview……Page 496
Contexts……Page 499
Attributes and Properties……Page 500
Remote Objects……Page 501
A Simple Server……Page 503
A Simple Client……Page 504
Channels……Page 505
Formatters……Page 509
ChannelServices and RemotingConfiguration……Page 510
Object Activation……Page 511
Passing Objects in Remote Methods……Page 515
Lifetime Management……Page 520
Configuration Files……Page 523
Hosting Applications……Page 533
Classes, Interfaces, and SoapSuds……Page 534
Asynchronous Remoting……Page 537
Remoting and Events……Page 538
Call Contexts……Page 544
Summary……Page 546
Localization……Page 548
Unicode Issues……Page 549
Cultures and Regions……Page 550
Cultures in Action……Page 555
Sorting……Page 559
Creating Resource Files……Page 561
ResourceWriter……Page 562
Using Resource Files……Page 563
Visual Studio .NET……Page 566
Outsourcing Translations……Page 572
Changing the Culture Programmatically……Page 573
Using Binary Resource Files……Page 575
Using XML Resource Files……Page 576
Globalization and Localization with ASP.NET……Page 578
A Custom Resource Reader……Page 579
Creating a DatabaseResourceReader……Page 580
Creating a DatabaseResourceSet……Page 581
Creating a DatabaseResourceManager……Page 582
Summary……Page 583
Designing for Deployment……Page 584
Deployment Requirements……Page 585
Simple Deployment……Page 586
Xcopy and Web Applications……Page 587
Copy Project……Page 589
What Is Windows Installer?……Page 590
Creating Installers……Page 591
Advanced Options……Page 601
Summary……Page 608
Part III: Windows Forms……Page 610
Windows Forms……Page 612
Creating a Windows Form Application……Page 613
Control Class……Page 618
User Interaction……Page 619
Class Hierarchy……Page 621
Standard Controls and Components……Page 623
Forms……Page 637
Form Class……Page 638
Multiple Document Interface (MDI)……Page 646
Custom Controls……Page 649
Summary……Page 661
Graphics with GDI+……Page 662
GDI and GDI+……Page 663
Drawing Shapes……Page 665
Painting Shapes Using OnPaint()……Page 668
Using the Clipping Region……Page 669
Point and PointF……Page 671
Size and SizeF……Page 673
Rectangle and RectangleF……Page 674
Region……Page 675
A Note about Debugging……Page 676
Drawing Scrollable Windows……Page 677
World, Page, and Device Coordinates……Page 683
Red-Green-Blue (RGB) Values……Page 684
Graphics Display Modes and the Safety Palette……Page 685
The Safety Palette……Page 686
Brushes……Page 687
Pens……Page 688
Drawing Shapes and Lines……Page 689
Displaying Images……Page 691
Drawing Text……Page 694
Simple Text Example……Page 695
Fonts and Font Families……Page 696
Example: Enumerating Font Families……Page 698
The CapsEditor Sample……Page 700
The Invalidate() Method……Page 705
Calculating Item Sizes and Document Size……Page 706
OnPaint()……Page 707
Coordinate Transforms……Page 709
Responding to User Input……Page 710
Printing……Page 714
Implementing Print and Print Preview……Page 715
Summary……Page 719
Part IV: Data……Page 722
ADO.NET Overview……Page 724
Shared Classes……Page 725
Database-Specific Classes……Page 726
Using Database Connections……Page 727
Using Connections Efficiently……Page 728
Transactions……Page 731
Commands……Page 732
Executing Commands……Page 733
Calling Stored Procedures……Page 737
Fast Data Access: The Data Reader……Page 740
Data Tables……Page 743
Data Columns……Page 744
Data Relationships……Page 750
Data Constraints……Page 752
XML Schemas……Page 754
Generating Code with XSD……Page 755
Populating a DataSet……Page 760
Populating a DataSet Class with a Data Adapter……Page 761
Persisting DataSet Changes……Page 762
Updating with Data Adapters……Page 763
Writing XML Output……Page 765
Tiered Development……Page 767
Key Generation with SQL Server……Page 769
Naming Conventions……Page 771
Summary……Page 773
Displaying Tabular Data……Page 774
Data Sources……Page 777
DataGrid Class Hierarchy……Page 785
Simple Binding……Page 789
Data-Binding Objects……Page 790
Visual Studio.NET and Data Access……Page 796
Creating a Connection……Page 797
Selecting Data……Page 798
Generating a DataSet……Page 801
Updating the Data Source……Page 802
Building a Schema……Page 803
Other Common Requirements……Page 809
Summary……Page 817
Manipulating XML……Page 820
Introducing the System.Xml Namespace……Page 821
Using MSXML in .NET……Page 822
Reading and Writing Streamed XML……Page 825
Using the XmlTextReader Class……Page 826
Using the XmlValidatingReader Class……Page 830
Using the XmlTextWriter Class……Page 833
Using the DOM in .NET……Page 834
Using the XmlDocument Class……Page 836
Using XPath and XSLT in .NET……Page 841
The System.Xml.XPath Namespace……Page 842
The System.Xml.Xsl Namespace……Page 846
Converting ADO.NET Data to XML……Page 851
Converting XML to ADO.NET Data……Page 859
Reading and Writing a DiffGram……Page 861
Serializing Objects in XML……Page 864
Serialization without Source Code Access……Page 872
Summary……Page 875
Working with Active Directory……Page 876
Features……Page 877
Active Directory Concepts……Page 878
Schema……Page 882
Active Directory Users and Computers……Page 884
ADSI Edit……Page 885
Active Directory Service Interfaces (ADSI)……Page 886
Programming Active Directory……Page 887
Binding……Page 888
Getting Directory Entries……Page 893
Object Collections……Page 894
Creating New Objects……Page 896
Updating Directory Entries……Page 897
Accessing Native ADSI Objects……Page 898
Searching in Active Directory……Page 899
Get the Schema Naming Context……Page 903
Get the Property Names of the User Class……Page 905
Search for User Objects……Page 906
Summary……Page 908
Part V: Web Programming……Page 910
ASP.NET Pages……Page 912
ASP.NET Introduction……Page 913
ASP.NET Web Forms……Page 914
ASP.NET Server Controls……Page 919
ADO.NET and Data Binding……Page 931
Updating the Event-Booking Application……Page 932
More on Data Binding……Page 940
Application Configuration……Page 945
Summary……Page 946
Web Services……Page 948
SOAP……Page 949
WSDL……Page 950
Exposing Web Services……Page 952
Consuming Web Services……Page 955
Extending the Event-Booking Example……Page 957
The Event-Booking Web Service……Page 958
The Event-Booking Client……Page 961
Exchanging Data Using SOAP Headers……Page 963
Summary……Page 968
User Controls and Custom Controls……Page 970
A Simple User Control……Page 971
Custom Controls……Page 978
Custom Control Project Configuration……Page 979
Basic Custom Controls……Page 983
Creating a Composite Custom Control……Page 988
A Straw Poll Control……Page 990
The Candidate Controls……Page 992
The StrawPoll Control Builder……Page 993
Straw Poll Style……Page 994
The Straw Poll Control……Page 995
Summary……Page 1001
Part VI: Interop……Page 1002
COM Interoperability……Page 1004
Freeing Memory……Page 1005
Interfaces……Page 1006
Threading……Page 1008
Error Handling……Page 1010
Marshaling……Page 1011
Creating a COM Component……Page 1012
Creating a Runtime Callable Wrapper……Page 1016
Adding Connection Points……Page 1019
Using ActiveX Controls in Windows Forms……Page 1021
Using a .NET Component from a COM Client……Page 1024
Creating a .NET Component……Page 1025
Creating a Type Library……Page 1026
COM Interop Attributes……Page 1028
COM Registration……Page 1031
Creating a COM Client……Page 1032
Adding Connection Points……Page 1034
Creating a Client with a Sink Object……Page 1035
Running Windows Forms Controls in Internet Explorer……Page 1036
Summary……Page 1037
History……Page 1038
Where to Use Enterprise Services?……Page 1039
Distributed Transactions……Page 1040
Loosely Coupled Events……Page 1041
Application Attributes……Page 1042
Creating the Component……Page 1043
Manual Deployment……Page 1044
Component Services Admin Tool……Page 1045
Client Application……Page 1047
Transaction Attributes……Page 1048
Transaction Results……Page 1049
Sample Application……Page 1050
Summary……Page 1060
Part VII: Windows Base Services……Page 1062
File and Registry Operations……Page 1064
Managing the File System……Page 1065
.NET Classes That Represent Files and Folders……Page 1066
The Path Class……Page 1068
Example: A File Browser……Page 1069
Example: FilePropertiesAndMovement……Page 1074
Reading and Writing to Files……Page 1078
Streams……Page 1079
Reading and Writing to Binary Files……Page 1081
Reading and Writing to Text Files……Page 1086
Reading and Writing to the Registry……Page 1093
The Registry……Page 1094
The .NET Registry Classes……Page 1096
Example: SelfPlacingWindow……Page 1098
Summary……Page 1105
Accessing the Internet……Page 1106
Basic Web Client Example……Page 1107
WebRequest and WebResponse Classes……Page 1109
Other WebRequest and WebResponse Features……Page 1110
Displaying Output as an HTML Page……Page 1113
The Web Request and Web Response Hierarchy……Page 1114
URIs……Page 1116
IP Addresses and DNS Names……Page 1118
Lower-Level Protocols……Page 1121
Lower-Level Classes……Page 1122
Summary……Page 1127
What Is a Windows Service?……Page 1130
Service Program……Page 1132
System.ServiceProcess Namespace……Page 1134
A Class Library Using Sockets……Page 1135
TcpClient Example……Page 1139
Windows Service Project……Page 1141
Service Installation……Page 1146
Installation Program……Page 1147
Monitoring and Controlling the Service……Page 1152
net.exe……Page 1153
sc.exe……Page 1154
ServiceController Class……Page 1155
Troubleshooting……Page 1161
Event Logging……Page 1162
Performance Monitoring……Page 1169
Summary……Page 1174
Appendixes……Page 26
Principles of Object – Oriented Programming……Page 1176
What Is an Object?……Page 1177
Class Members……Page 1178
Defining a Class……Page 1179
Instantiating and Using Objects……Page 1180
Using Static Members……Page 1182
A Note About Reference Types……Page 1186
Overloading Methods……Page 1187
Properties……Page 1189
Using Inheritance in C#……Page 1191
Class Hierarchies and Class Design……Page 1198
Polymorphism and Virtual Members……Page 1200
Method Hiding……Page 1203
Abstract Functions and Base Classes……Page 1204
Sealed Classes and Methods……Page 1208
Interfaces……Page 1209
Construction and Disposal……Page 1210
Creating Constructors……Page 1211
Summary……Page 1213
Differences Between C# and Visual Basic……Page 1216
Classes……Page 1217
Conventions……Page 1218
SquareRoot Visual Basic Version……Page 1219
Basic Syntax……Page 1220
Methods……Page 1223
Variables……Page 1224
Classes……Page 1226
If Statements……Page 1227
Extra Code in C#……Page 1228
What Happens When You Run a Program……Page 1229
The C# Code for the Rest of the Program……Page 1231
Program Entry Point……Page 1234
Instantiating Classes……Page 1235
The SquareRootForm Class……Page 1237
Example: Employees and Managers……Page 1241
The Visual Basic Employee Class Module……Page 1242
Static Members……Page 1247
Inheritance……Page 1249
Inheriting from the Employee Class……Page 1250
The Manager Class……Page 1251
Method Overrides……Page 1252
The Manager Constructors……Page 1253
Method Overloading……Page 1254
Using the Employee and Manager Classes……Page 1255
References to Derived Classes……Page 1256
Arrays of Objects……Page 1257
The for Loop……Page 1259
Data Types……Page 1260
Operators……Page 1261
Summary……Page 1263
Starting Out……Page 1264
Namespaces……Page 1265
Declaring Variables……Page 1268
Value Types……Page 1269
Type Conversion and Casting……Page 1275
Operators……Page 1276
Flow Control and Iteration……Page 1277
Classes……Page 1279
Class Members……Page 1280
Class Inheritance……Page 1284
Input and Output……Page 1288
Summary……Page 1290
C# for C++ Developers……Page 1292
Terminology……Page 1293
Differences……Page 1294
Similarities……Page 1295
New Base Class Features……Page 1296
The Hello World Example……Page 1297
Namespaces……Page 1298
Displaying the Message……Page 1299
Program Architecture……Page 1300
Language Syntax……Page 1301
Program Flow……Page 1302
Variables……Page 1305
Memory Management……Page 1312
Methods……Page 1314
Properties……Page 1315
Operators……Page 1316
Classes……Page 1318
Constants……Page 1326
Operator Overloading……Page 1328
Arrays……Page 1332
Enumerations……Page 1335
Exceptions……Page 1336
Pointers and Unsafe Code……Page 1337
Interfaces……Page 1339
Delegates……Page 1341
Events……Page 1342
Preprocessor Directives……Page 1343
Summary……Page 1344
SYMBOLS……Page 1346
A……Page 1347
B……Page 1351
C……Page 1352
D……Page 1358
E……Page 1362
F……Page 1365
G……Page 1367
I……Page 1369
J……Page 1371
L……Page 1372
M……Page 1373
N……Page 1375
O……Page 1376
P……Page 1378
Q……Page 1379
R……Page 1380
S……Page 1382
T……Page 1386
V……Page 1389
W……Page 1391
X……Page 1394
End Of Book……Page 1395

Reviews

There are no reviews yet.

Be the first to review “Professional C#”
Shopping Cart
Scroll to Top