C# for Java Developers

Adam Freeman, Allen Jones

  • 出版商: MicroSoft
  • 出版日期: 2002-08-24
  • 售價: $1,860
  • 貴賓價: 9.5$1,767
  • 語言: 英文
  • 頁數: 576
  • 裝訂: Paperback
  • ISBN: 0735617791
  • ISBN-13: 9780735617797
  • 相關分類: C#Java 程式語言
  • 已絕版

買這商品的人也買了...

相關主題

商品描述

Java developers—learn C# quickly and thoroughly with this book!

Although Java and C# share many similarities, there are fundamental differences between them. What’s more, C#—the language designed from the ground up for programming the Microsoft® .NET Framework—offers a wealth of new features that enable programmers to tap the full power of.NET. This is the ideal guide to help any Java developer master .NET programming with C#. The authors—two Java and C# experts—reveal the similarities and differences between the two platforms these languages support. Then they show you how to leverage your Java experience to get up to speed in C# development with a minimum of difficulty. It’s the definitive programming resource as you tackle the .NET class libraries and learn to write applications for .NET with C#. Topics covered include:

OVERVIEW
• Introduction to Microsoft .NET
• Comparing Java and .NET technologies

THE C# LANGUAGE
• Creating assemblies
• Language syntax and features
• Data types
• Advanced language features

PROGRAMMING .NET WITH C#
• Strings and regular expressions
• Numbers and dates
• Collections
• Streams, files, and I/O
• XML processing

ADVANCED TOPICS
• Reflection
• Threading and synchronization
• Networking
• Remoting
• Database connectivity
• Security and cryptography
• Graphics and UI
• Introduction to XML Web services

PRAISE FOR THIS BOOK FROM THE MICROSOFT VISUAL C# TM .NET TEAM:
The two tech veterans who wrote this book can help you master C# quickly. They do an admirable job of describing the basics of the .NET initiative: its goals, structure, and capabilities. Then they help you leap the biggest hurdle of all—understanding the structure and purpose of the .NET class libraries. Their book presents the underlying concepts, explains the challenges you’ll face, and guides you past the pitfalls with ease.
—Prashant Sridharan, Product Manager, Microsoft Visual C# .NET team

Table of Contents

Introduction xxi
PART I  
1  Introduction to Microsoft .NET 3
    Background 3
    Goals of .NET 5
        System Integration Using XML 5
        Platform Neutrality 5
        Language Neutrality 6
        Technology Consolidation 7
    Overview of .NET 7
        The .NET Framework 7
        Development Tools 9
        Server Products 12
        Devices and Clients 13
        Building Block Services 13
    Platform Migration and Integration 14
        Web Services and Open Standards 14
        Java User Migration Path to Microsoft .NET 15
        Third-Party Products 15
        Skills Transfer 16
2  Comparing Java and .NET Technologies 17
    Java 2 Platform, Standard Edition 18
    Java 2 Platform, Enterprise Edition 20
PART II  THE C# LANGUAGE  
3  Creating Assemblies 25
    Using the C# Compiler 25
    Other .NET Framework Tools 28
    Assemblies 29
        Contents of an Assembly 29
        Single-File and Multifile Assemblies 31
4  Language Syntax and Features 37
    General Program Structure 37
        The Main Method 38
        Comments 39
        Documentation Comments 39
        Case Sensitivity 39
        Naming Conventions 40
        Source Code Character Sets and Unicode 40
        Identifiers 41
        Source File Names and Contents 41
    Keywords 41
        Package and Namespace Keywords 41
        Simple Type and Constant Keywords 42
        Type Declaration, Access, and Manipulation Keywords 43
        Modifier Keywords 45
        Flow Control Keywords 46
        Exception Handling Keywords 47
        Unmanaged Code Keywords 48
        Keywords as Identifiers 48
    Operators 49
        Precedence and Associativity 50
    Literals 51
    Modifiers 52
        Access Modifiers 52
        Inheritance Modifiers 53
        Other Modifiers 54
    Namespaces 56
        Declaring Namespaces 56
        Using Namespaces 57
    Statements 58
        Labeled Statements 59
        Selection and Iteration Statements 59
        Jump Statements 61
        Other Statements 62
5  Data Types 65
    Types 65
        Unified Type System 66
        Value Types 68
        Reference Types 76
        Conversion 85
    Members 88
        Member Types and Declaration Context 88
        Versioning and Inheritance of Members 89
        Static Members 91
        Member Attributes 91
        Member Modifiers 91
        Constants 91
        Fields 92
        Static and Instance Constructors 95
        Destructors 97
        Methods 98
        Events 100
        Properties 105
        Indexers 108
        Operators 111
        Nested Types 116
    Variables 116
        Value Parameters 117
        Reference Parameters 118
        Output Parameters 119
6  Advanced Language Features 121
    Threading and Synchronization 121
    Exceptions and Exception Handling 122
        Declaring Exceptions 122
        Catching Exceptions 122
        Throwing Exceptions 123
        The Exception Hierarchy 124
        The System.Exception Class 124
    Attributes 126
        Attribute Names 127
        Attribute Specification 127
        Custom Attributes 129
        Compile-Time Attributes 131
    Assertions 133
    Preprocessor Directives 133
        #define and #undef 134
        #if, #elif, #else, and #endif 134
        #region and #endregion 136
        #warning and #error 136
        #line 137
    Unsafe Code 137
        The unsafe Modifier 137
        The /unsafe Compiler Flag 138
        Managed and Unmanaged Types 138
        The sizeof Operator 139
        Pointers 139
        The fixed Statement 142
        The stackalloc Command 143
PART III  PROGRAMMING .NET WITH C#  
7  Strings and Regular Expressions 147
    Strings 147
        Creating Strings 148
        Comparing Strings 149
        Copying Strings 150
        String Length 150
        String Concatenation 150
        Changing Case 151
        Working with Characters 151
        Working with Substrings 152
        Splitting Strings 153
        Strings as Keys 153
        Parsing Strings 153
        Formatting Strings 154
        Encoding Strings 157
        Dynamically Building Strings 162
    Regular Expressions 164
        Compiling Regular Expressions 164
        Manipulating Text 166
        Ad Hoc Regular Expressions 171
8  Numbers and Dates 173
    Numbers 173
        Numbers as Objects 173
        Converting Numbers 177
        Formatting Numbers 177
        Mathematical Functions 181
        Random Numbers 182
    Dates and Times 183
        Creating Dates 184
        Manipulating Dates 185
        Formatting Dates 186
        Parsing Strings 186
9  Collections 187
    Indexers 187
    Collection Interfaces 189
        ICollection 190
        IEnumerable, IEnumerator, and the foreach Keyword 190
        IComparer and IComparable 193
        Other Collection Interfaces 194
    Basic Collections 194
        Arrays 194
        Hashtable 196
        ArrayList 198
        Queue 199
        Stack 200
        SortedList 201
    Specialized Collections 202
        Strongly Typed Collections 202
        Unusual Collections 203
    The CollectionsUtil Class 203
    Synchronization 204
    Custom Collections 205
10  Streams, Files, and I/O 207
    Working with the Console 207
        Writing to the Console 208
        Reading from the Console 209
        Changing the Console Streams 209
        Console Summary 209
    The File System 210
        Paths 210
        Files and Directories 212
    Streams 218
        The Foundation of Streams 218
        Base Streams 219
        Pass-Through Streams 222
        Readers and Writers 222
        Synchronizing Streams 225
        Streams Summary 225
    Asynchronous I/O 225
        Asynchronous I/O Summary 228
    Isolated Storage 228
        Obtaining and Managing the Isolated Stores 229
        Reading and Writing Isolated Data 231
        Isolated Storage Summary 232
    Object Serialization 232
        Simple Serialization 233
        Selective Serialization 235
        Custom Serialization 235
11  XML Processing 239
    XmlNameTable 240
    XmlReader 241
        XmlTextReader 241
        XmlValidatingReader 251
        XmlNodeReader 255
    XmlWriter 255
        XmlTextWriter 256
    Document Object Model 260
        Key Classes 260
        Document Creation 261
        Other Key Differences 262
    XPath 262
        IXPathNavigable 262
        XPathDocument 263
        XPathNavigator 263
    XSL Transformations 269
        Creating a Transformer 269
        Loading a Style Sheet 270
        Transforming XML Data 270
    Extensibility 271
PART IV  ADVANCED TOPICS  
12  Reflection 275
    Dealing with Types 275
        Local Types 275
        Foreign Types 276
    Inspecting Types 277
        Inspecting Constructors and Methods 280
        Inspecting Properties 282
        Inspecting Events 283
        Inspecting Parameters 283
        Inspecting Fields 284
        Inspecting Attributes 285
        Late Binding 285
        Instantiation 286
        Manipulation 286
13  Threading and Synchronization 289
    Threads 290
        Creating and Starting Threads 290
        Suspending and Resuming Threads 291
        Stopping Threads 292
        Setting Thread Priorities 294
        Thread States 294
        Interrupting a Thread 296
        Local Thread Data 297
        Timers 298
        Basic Threading Summary 301
    The ThreadPool Class 302
        Explicit Thread Alternative 302
        Waiting for an Event 303
    Synchronization 304
        Basic Locking 305
        Waiting and Notifying 306
        ReaderWriterLock 307
        WaitHandle 308
14  Networking 311
    Accessing the Internet 312
        URLs and URIs 312
        The WebClient Class 315
        WebRequest and WebResponse 318
        HTTP Connection Features 323
        Names and Addresses 325
    Sockets 329
        Creating a TCP Client 329
        Creating a TCP Server 332
        Using UDP 334
    Programming with Native Sockets 335
        Creating Sockets 335
        Client Sockets 335
        Server Sockets 336
        Configuring Sockets 337
        Asynchronous Sockets 338
15  Remoting 341
    First Steps 341
        Creating the Server 342
        Creating the Client 344
        Building and Testing the Example 346
    Copies and References 347
    Channels 348
        Creating a Channel 349
        Registering a Channel 351
        Using More than One Channel 351
    Publishing and Activation 353
        Client Activation 354
        Server Activation 354
        Using Configuration Files 356
        Publishing Limitations and Scope 360
    Lifetime Leases 360
        Configuring a Lease 361
        Renewing a Lease 362
        Setting Lease Defaults 364
16  Database Connectivity 365
    Data Providers 366
        Interfaces and Implementations 366
        Data Provider Sample Code 368
        Connections 372
        Transactions 374
        Commands 376
    DataSet 386
        DataSet Component Classes 387
        Creating a DataSet 388
        Managing a DataSet with a Data Adapter 389
        Manually Managing a DataSet 391
        XML Support 392
17  Security and Cryptography 397
    Code Access Security 397
        Programming for CAS 398
        Declarative CAS Statements 399
        Imperative Security Demands 404
        CAS Policies 405
    Role-Based Security 406
    Cryptography 409
        Encrypting and Decrypting Data 409
        Hash Codes 413
        Digital Signatures 415
18  Graphics and UI 419
    Windows Forms 419
        Using Windows Forms 420
        Control Overview 421
        Docking and Anchoring 424
        Handling Events 426
    Drawing with GDI+ 427
        Obtaining a Graphics Instance 427
        Lines, Shapes, and Curves 428
        Drawing Strings 431
        Drawing Images 432
        Double Buffering 433
19  Introduction to XML Web Services 435
    Creating XML Web Services 436
    Building and Deploying XML Web Services 438
        Deployment Directory 438
        Compiling 438
        Creating the Directive 439
        Configuring XML Web Services 439
        Testing XML Web Services 441
        Summary 441
    State Management 441
        Application State Management 442
        Session State Management 442
    XML Web Service Clients 443
        Creating a Proxy Class 443
        Using a Proxy Class 444
        Asynchronous Programming 445
A  Platform Integration 447
    Runtime Environment 447
        Command-Line Arguments 448
        Environment Variables 448
        Drives and Directories 448
        Machine and Operating System Information 449
    Process Control 450
        Creating New Processes 450
        Obtaining a Reference to an Existing Process 451
        Terminating Processes 452
        Information About Existing Processes 452
        Process Synchronization and Events 453
    Windows Registry 454
        The Registry Class 454
        The RegistryKey Class 455
        Remote Registry Access 456
    Windows Event Log 456
        Writing to the Event Log 456
        Reading from the Event Log 458
        Creating and Deleting Custom Logs 460
        Event Log Notifications 460
    Windows Services 462
        The Service Application 462
        Service Installer 466
        Service Controller 469
B  Shared Assemblies 473
    Creating a Shared Assembly 473
    The Global Assembly Cache 474
        Assembly Versions 475
    Assembly Probing 478
    Codebase Probing 479
C  Configuring Applications 481
    Application Configuration Files 481
        Specifying a CLR Version 482
        Using Concurrent Garbage Collection 482
        Managing Assembly Versions and Locations 483
        Registering Remote Objects 483
    Application Settings 483
        Simple Settings 483
        Complex Settings 484
D  Garbage Collection 489
    Controlling the Garbage Collector 489
        Forcing a Collection 489
        Generations 490
        Concurrent Collection 491
    Finalizing and Disposing 491
        Destructors 492
        Resurrection 493
    Weak References 494
E  Cross-Language Code Interoperability 495
    The Common Type System 496
    The Common Language Specification 496
    Writing CLS-Compliant Code in C# 496
    The CLSCompliant Attribute 497
F  Java to .NET API Reference 501
    The java.awt Package 501
    The java.awt.color Package 504
    The java.awt.datatransfer Package 504
    The java.awt.dnd Package 504
    The java.awt.event Package 504
    The java.awt.font Package 505
    The java.awt.geom Package 506
    The java.awt.im Package 506
    The java.awt.im.spi Package 506
    The java.awt.image Package 506
    The java.awt.image.renderable Package 506
    The java.awt.print Package 506
    The java.io Package 507
    The java.lang Package 508
    The java.lang.ref Package 510
    The java.lang.reflect Package 510
    The java.math Package 510
    The java.net Package 511
    The java.nio Package 512
    The java.rmi Package 512
    The java.security Package 512
    The java.sql Package 512
    The java.text Package 515
    The java.util Package 515
    The java.util.jar Package 517
    The java.util.logging Package 517
    The java.util.prefs Package 517
    The java.util.regex Package 517
    The java.util.zip Package 518
    The javax.swing Package 518
    The javax.swing.border Package 522
    The javax.swing.colorchooser Package 522
    The javax.swing.event Package 522
    The javax.swing.filechooser Package 523
    The javax.swing.plaf Package 523
    The javax.swing.table Package 523
    The javax.swing.text Package 523
    The javax.swing.tree Package 524
    The javax.swing.undo Package 524
    The javax.sql Package 524
    The javax.xml.parsers Package 524
    The javax.xml.transform Package 524
    The org.w3c.dom Package 525
    The org.xml.sax Package 526
INDEX 527