Inside C#, 2/e
暫譯: C# 內部解析,第二版

Tom Archer, Andrew Whitechapel

  • 出版商: MicroSoft
  • 出版日期: 2002-04-01
  • 售價: $2,050
  • 貴賓價: 9.5$1,948
  • 語言: 英文
  • 頁數: 600
  • 裝訂: Paperback
  • ISBN: 0735616485
  • ISBN-13: 9780735616486
  • 相關分類: C#
  • 已過版

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

商品描述

Description:

Get the in-depth architectural information you need about the hottest OOP language for Microsoft® .NET—now updated for final release code.

Take a detailed look at the internal architecture of the groundbreaking C# language with this architectural reference. It’s fully updated with information about the Microsoft® .NET platform and Microsoft Visual Studio® .NET. It’s packed with sample code and demo applications to show you exactly how to develop with C#. You’ll explore this advanced language and its design parameters and construction to gain a complete understanding of how it works—and why it works that way. Topics covered include:

C# CLASS FUNDAMENTALS
• Building C# applications and libraries
• The .NET type system
• Classes and structs
• Methods, properties, arrays, indexers, and attributes
• Interfaces

WRITING CODE
• Expressions and operators
• Program flow control
• String handling and regular expressions
• File I/O with streams
• Error handling with exceptions
• Operator overloading and user-defined conversions
• Delegates and event handlers
• Documentation with XML

ADVANCED C#
• Numerical processing and the Math class
• Collections and object enumeration
• Multithreaded programming
• Querying metadata with reflection
• Deterministic finalization and the Dispose pattern
• Pinning and memory management
• Using COM from C# applications
• .NET components in unmanaged code
• Incorporating security

CD-ROM FEATURES:
• A fully searchable electronic copy of the book
• Sample code in C# (also available at
www.microsoft.com/mspress/books/5861.asp)

 

 

Table of Contents:

Foreword xix
Introduction xxiii
PART 1   C# CLASS FUNDAMENTALS  
1   Building C# Applications and Libraries 3
    "Hello, World"—The Command-Line Version 4
        Using the Command-Line Compiler 4
    "Hello, World" Code Walk-Through 7
        One-Stop Programming 7
        Namespaces 8
        Classes and Members 10
        The Main Method 11
        The System.Console.WriteLine Method 11
        Namespaces and the using Directive 12
        Skeleton Code 13
        Class Ambiguity 14
    "Hello, World"—The Visual Studio .NET Version 15
    Building and Running .NET Applications 18
    Inside "Hello, World" 20
    Working with Assemblies and Modules 24
        Assembly Overview 25
        Benefits of Assemblies 26
        Building Assemblies 27
        Creating Shared Assemblies 32
        Working with the Global Assembly Cache 35
    Summary 37
2   The .NET Type System 39
    Everything Is an Object 40
        The Root of All Types: System.Object 41
    Value Types and Reference Types 43
        Value Types 43
        Reference Types 44
    Boxing and Unboxing 45
        Converting from Value Types to Reference Types 45
        Converting from Reference Types to Value Types 46
        More Boxing Examples 48
    Types and Aliases 53
    Casting Between Types 54
    CTS Benefits 56
        Language Interoperability 57
        Singly Rooted Object Hierarchy 57
        Type Safety 58
    Summary 58
3   Classes and Structs 59
    Defining Classes 59
    Class Members 60
    Access Modifiers 62
    The Main Method 63
        Command-Line Arguments 64
        Returning Values from Main 66
        Multiple Main Methods 67
    Constructors 68
        Static Members and Instance Members 71
        Constructor Initializers 73
        Specifying Run-Time Information in a Constructor Initializer 78
    Constants vs. Read-Only Fields 81
        Constants 81
        Read-Only Fields 83
    Inheritance 87
        Multiple Interfaces 90
        Sealed Classes 91
    Defining Structs in C# 92
        Struct Usage 92
        Guidelines to Using Structs 95
    Summary 97
4   Methods 99
    Value and Reference Parameters 100
        ref Method Parameters 101
        out Method Parameters 105
    Value and Reference Parameters (Again) 109
    Method Overloading 113
        Overloading Constructors 115
        Inheritance and Overloading 118
    Variable Method Parameters 119
    Virtual Methods 122
        Method Overriding 123
        Polymorphism 124
        new and virtual Methods 131
        Calling Virtual Methods from Constructors 134
    Static Methods 136
        Access to Class Members 137
        Static Constructors 138
    Summary 140
5   Properties, Arrays, and Indexers 141
    Properties as Smart Fields 142
        Defining and Using Properties 143
        Inside Properties 145
        Inheriting Properties 150
        Advanced Use of Properties 155
    Arrays 156
        Declaring Arrays 156
        Single-Dimensional Array Example 157
        Multidimensional Arrays 158
        Querying for Rank 160
        Jagged Arrays 162
    Treating Objects Like Arrays by Using Indexers 164
        Defining Indexers 165
        Indexer Example 165
        Inside Indexers 167
        Design Guidelines 169
    Summary 170
6   Attributes 171
    Introducing Attributes 172
    Defining Attributes 173
    Querying for Attributes 177
        Class Attributes 177
        Method Attributes 180
        Field Attributes 182
    Attribute Parameters 184
        Positional Parameters and Named Parameters 184
        Common Mistakes with Named Parameters 186
        Valid Attribute Parameter Types 187
    The AttributeUsage Attribute 187
        Defining an Attribute Target 188
        Single-Use and Multiuse Attributes 190
        Specifying Inheritance Attribute Rules 191
    Attribute Identifiers 193
    Predefined Attributes 195
        Conditional Attribute 197
        Obsolete Attribute 199
        CLSCompliant Attribute 200
        DllImport and StructLayout Attributes 201
        Assembly Attributes 203
    Context Attributes 205
    Summary 212
7   Interfaces 213
    Interface Use 214
    Declaring Interfaces 215
    Implementing Interfaces 217
        Querying for Implementation by Using is 219
        Querying for Implementation by Using as 224
        Interfaces vs. the Alternatives 227
    Explicit Interface Member Name Qualification 230
        Name Hiding with Interfaces 230
        Avoiding Name Ambiguity 233
    Interfaces and Inheritance 238
    Combining Interfaces 242
    Summary 245
PART II   WRITING CODE  
8   Expressions and Operators 249
    Operators Defined 249
    Operator Precedence 250
        How C# Determines Precedence 251
        Left and Right Associativity 252
        Practical Usage 253
    C# Operators 253
        Primary Expression Operators 253
        Mathematical Operators 259
    Numeric Conversions 269
        checked and unchecked Context 271
    Bitwise Operators 272
        Relational Operators 276
        Simple Assignment Operators 278
        The Conditional Operator 282
    Summary 284
9   Program Flow Control 285
    Selection Statements 285
        The if Statement 285
        The switch Statement 292
    Iteration Statements 301
        The while Statement 301
        The do/while Statement 302
        The for Statement 305
        The foreach Statement 310
    Branching with Jump Statements 313
        The break Statement 313
        The continue Statement 317
        The Infamous goto Statement 319
        The return Statement 326
    Summary 327
10   String Handling and Regular Expressions 329
    Strings 330
        String Formatting 333
        Format Specifiers 334
        Objects and ToString 338
        Numeric String Parsing 339
        Strings and DateTime 341
        Encoding Strings 345
        The StringBuilder Class 346
        Splitting Strings 347
        Extending Strings 348
        String Interning 350
    Regular Expressions 353
        Match and MatchCollection 358
        Groups and Captures 361
        String-Modifying Expressions 363
        Regular Expression Options 367
        Compiling Regular Expressions 368
    Summary 372
11   File I/O with Streams 373
    Stream Classes 373
        FileStream 375
        StreamReader and StreamWriter 379
        Memory and Buffered Streams 381
        String Readers and Writers 384
        Binary Readers and Writers 387
    File System Classes 389
        Directory and DirectoryInfo 389
        File and FileInfo 392
        Parsing Paths 394
    Nonconsole Use of Streams 395
        Windows OpenFileDialog 395
        Reading Web Pages 397
    Serialization 399
        Serializing with BinaryFormatter 399
        Serializing with SoapFormatter 403
        Serializing with XmlSerializer 404
        Implementing Iserializable 406
    Summary 409
12   Error Handling with Exceptions 411
    Overview of Exception Handling 411
    Basic Exception-Handling Syntax 413
        Throwing an Exception 413
        Catching an Exception 414
        Rethrowing an Exception 418
        Cleaning Up with finally 420
    Retrying Code 424
    Comparing Error-Handling Techniques 426
        Benefits of Exception Handling Over Return Codes 427
        Handling Errors in the Correct Context 429
        Improving Code Readability 430
        Throwing Exceptions from Constructors 432
    Using the System.Exception Class 432
        Constructing an Exception Object 432
        Using the StackTrace Property 436
        Catching Multiple Exception Types 437
        Deriving Your Own Exception Classes 438
    Designing Your Code with Exception Handling 441
        Design Issues with the try Block 441
        Design Issues with the catch Block 445
    Summary 448
13   Operator Overloading and User-Defined Conversions 449
    Operator Overloading 450
        Operator Overloading Syntax 450
        Operator Overloading Rules and Restrictions 451
        Operator Overloading Examples 453
        RGB Color Incrementing Example 456
        Operator Overloading Design Guidelines 462
    User-Defined Conversions 464
        User-Defined Conversion Syntax 465
        User-Defined Conversion Rules and Restrictions 465
        User-Defined Conversion Examples 465
    Summary 479
14   Delegates and Event Handlers 481
    Using Delegates as Callback Methods 481
    Inside Delegates 485
    Defining Delegates as Static Members 489
    Creating Delegates Only When Needed 492
    Multicast Delegates 495
        Multicast Delegate Justification 501
    Defining Events with Multicast Delegates 504
    Summary 509
15   Documentation with XML 511
    Getting Started 511
        Adding Elements 514
        Acceptable Code Constructs 514
    Compiler-Generated Element IDs 515
        Fields, Properties, Events, and Indexers 516
        Methods 518
    Well-Formed XML 523
    Comment Web Pages 525
    Element Tags and Attributes 526
        The <exception> Tag and cref Attribute 528
        The <c>, <code>, and <example> Tags 529
        The <include> Tag 530
        The <list> Tag 533
    Custom Formatting 534
    XML and Data 537
    Summary 539
ADVANCED C#  
16   Numerical Processing and the Math Class 543
    Numeric Support in C# and .NET 543
        Is the Decimal Type a Primitive? 545
        Numeric Suffixes 547
        A Numeric Type by Any Other Name. 547
        More on Numeric Literals 549
    Integral Ranges and Overflow Rules 552
    The Decimal Type 557
    The System.Math Class 558
    System.Math Constants 558
        Working with a Number's Sign 558
        Minimum and Maximum Values 559
        Methods for Rounding and Truncating 560
    Summary 560
17   Collections and Object Enumeration 563
    Implementing the Enumeration Interface 563
        Using an Enumerator Object 568
        Using the foreach Statement with Collections 569
    Two Interfaces for the Price of One 571
    Constructing Enumerator Objects 572
    Creating

商品描述(中文翻譯)

描述:

獲取有關 Microsoft® .NET 最熱門的物件導向程式設計語言 C# 的深入架構資訊——現在已更新至最終版本代碼。

透過這本架構參考書,詳細了解開創性的 C# 語言的內部架構。它已全面更新,包含有關 Microsoft® .NET 平台和 Microsoft Visual Studio® .NET 的資訊。書中充滿了範例代碼和示範應用程式,讓您確切了解如何使用 C# 開發。您將探索這種先進語言及其設計參數和結構,以全面理解其運作方式及原因。涵蓋的主題包括:

C# 類別基礎
• 建立 C# 應用程式和函式庫
• .NET 類型系統
• 類別和結構
• 方法、屬性、陣列、索引器和屬性
• 介面

編寫代碼
• 表達式和運算子
• 程式流程控制
• 字串處理和正則表達式
• 使用串流進行檔案 I/O
• 使用例外進行錯誤處理
• 運算子重載和使用者定義轉換
• 委派和事件處理器
• 使用 XML 進行文檔編寫

進階 C#
• 數值處理和 Math 類別
• 集合和物件列舉
• 多執行緒程式設計
• 使用反射查詢元數據
• 確定性終結和 Dispose 模式
• 鎖定和記憶體管理
• 從 C# 應用程式使用 COM
• 在非管理代碼中使用 .NET 元件
• 整合安全性

CD-ROM 特點:
• 一本可完全搜尋的電子書副本
• C# 的範例代碼(也可在 www.microsoft.com/mspress/books/5861.asp 獲得)

目錄:

前言 xix
介紹 xxiii
第一部分 C# 類別基礎
1 建立 C# 應用程式和函式庫 3
'Hello, World'—命令列版本 4
使用命令列編譯器 4
'Hello, World' 代碼逐步解析 7
一站式程式設計 7
命名空間 8
類別和成員 10
Main 方法 11
System.Console.WriteLine 方法 11
命名空間和 using 指令 12
骨架代碼 13
類別歧義 14
'Hello, World'—Visual Studio .NET 版本 15
建立和執行 .NET 應用程式 18
'Hello, World' 內部 20
使用組件和模組 24
組件概述 25
組件的好處 26
建立組件 27
創建共享組件 32
使用全域組件快取 35
總結 37
2 .NET 類型系統 39
一切皆為物件 40
所有類型的根:System.Object 41
值類型和參考類型 43
值類型 43
參考類型 44
裝箱和拆箱 45
從值類型轉換為參考類型 45
從參考類型轉換為值類型 46
更多裝箱範例 48
類型和別名 53
類型之間的轉換 54
CTS 的好處 56
語言互操作性 57
單根物件層次結構 57
類型安全 58
總結 58
3 類別和構造 59
定義類別 59
類別成員 59

最後瀏覽商品 (17)