 |
-- 會員 / 註冊 --
|
|
|
|
Essential C# 2.0 (英文版) ( 簡體 字) |
作者:[美]Mark Michaelis | 類別:1. -> 程式設計 -> .NET -> C# |
譯者: |
出版社:人民郵電出版社 | 3dWoo書號: 9817 詢問書籍請說出此書號!【缺書】 【不接受訂購】 |
出版日:12/1/2007 |
頁數:720 |
光碟數:1 |
|
站長推薦:  |
印刷: | 語系: ( 簡體 版 ) |
|
【不接受訂購】 | ISBN:9787115166876 |
作者序 | 譯者序 | 前言 | 內容簡介 | 目錄 | 序 |
(簡體書上所述之下載連結耗時費功, 恕不適用在台灣, 若讀者需要請自行嘗試, 恕不保證) |
作者序: |
譯者序: |
前言: |
內容簡介:本書以大量實例,詳盡地闡述了C# 2.0的核心特性,指導方針和最佳實踐。書中代碼採用了專門的格式,並採用 “知識地圖”的形式概括出每一章的主要內容。 本書全面講解了C#語言,讀者從中能夠學到:C#基底資料型別、數值型別、參考類型、類型轉換和陣列;運算子、控制流、迴圈、條件邏輯和順序程式設計;方法、參數、異常處理和結構化程式設計;類、遺傳、結構介面和物件導向程式設計;結構良好的類型、運算子重載、命名空間和垃圾回收;泛型、集合和反覆運算子;映射、屬性和宣告式程式設計;執行緒、同步和多執行緒模式;互通性和不安全代碼;C#通用語言基礎結構(CLI)。 本書內容全面系統,並經過精心編排,相信無論是初學程式設計的新手、有其他語言程式設計經驗的開發者或是專業C#程式師,閱讀本書都將受益匪淺。
|
目錄:1 Introducing C# 1 Hello, World 2 Compiling and Running the Application 3 Managed Execution and the Common Language Infrastructure 4 C# Syntax Fundamentals 7 C# Keywords 7 Type Definition 9 Main 10 Statements and Statement Delimiters 12 Whitespace 13 Working with Variables 14 Data Types 15 Declaring a Variable 16 Assigning a Variable 16 Using a Variable 18 Console Input and Output 18 Getting Input from the Console 18 Writing Output to the Console 20 Comments 22 Common Intermediate Language and ILDASM 25 2 Data Types 29 Fundamental Numeric Types 30 Integer Types 30 Floating-Point Types (float, double) 31 Decimal Type 32 Literal Values 33 More Fundamental Types 38 Boolean Type (bool) 38 Character Type (char) 39 Strings 41 null and void 49 null 49 The void Nontype 50 Categories of Types 50 Value Types 50 Reference Types 51 Nullable Modifier 53 Conversions between Data Types 53 Explicit Cast 54 Implicit Cast 57 Type Conversion without Casting 58 Arrays 60 Declaring an Array 60 Instantiating and Assigning Arrays 61 Using an Array 65 Strings as Arrays 71 Common Errors 73 3 Operators and Control Flow 77 Operators 78 Plus and Minus Unary Operators (+, -) 78 Arithmetic Binary Operators (+, -, *, /, %) 79 Parenthesis Operator 86 Assignment Operators (+=, -=, *=, /=, %=) 87 Increment and Decrement Operators (++, --) 88 Constant Expressions (const) 92 Introducing Flow Control 92 if Statement 96 Nested if 97 Code Blocks ({}) 99 Scope 101 Boolean Expressions 102 Relational and Equality Operators 103 Logical Boolean Operators 104 Logical Negation Operator (!) 106 Conditional Operator (?) 107 Bitwise Operators ( , , |, &, ^, ~) 108 Shift Operators ( , , =, =) 109 Bitwise Operators (&, |, ^) 110 Bitwise Assignment Operators (&=, |=, ^=) 112 Bitwise Complement Operator (~) 113 Control Flow Statements, Continued 113 The while and do/while Loops 113 The for loop 116 The foreach Loop 119 The switch Statement 122 Jump Statements 124 The break Statement 124 The continue Statement 127 The goto Statement 128 C# Preprocessor Directives 130 Excluding and Including Code (#if, #elif, #else, #endif) 131 Defining Preprocessor Symbols (#define, #undef) 132 Emitting Errors and Warnings (#error, #warning) 133 Turning Off Warning Messages (#pragma) 134 nowarn: warn list Option 134 Specifying Line Numbers (#line) 135 Hints for Visual Editors (#region, #endregion) 135 4 Methods and Parameters 139 Calling a Method 140 Namespace 142 Type Name 144 Scope 144 Method Name 145 Parameters 145 Method Return 145 Statement versus Method Call 146 Declaring a Method 146 Parameter Declaration 148 Method Return Declaration 149 The using Directive 151 Aliasing 154 Returns and Parameters on Main() 155 Parameters 158 Value Parameters 158 Reference Parameters (ref) 160 Output Parameters (out) 161 Parameter Arrays (params) 163 Recursion 166 Method Overloading 169 Basic Error Handling with Exceptions 171 Trapping Errors 173 Reporting Errors Using a throw Statement 181 5 Classes 185 Defining and Instantiating a Class 189 Instance Fields 193 Declaring an Instance Field 193 Accessing an Instance Field 194 Instance Methods 195 Using the this Keyword 196 Access Modifiers 202 Constructors 204 Declaring a Constructor 205 Default Constructors 206 Overloading Constructors 208 Calling Another Constructor Using this 209 Static 211 Static Fields 212 Static Methods 215 Static Constructors 215 Static Classes 216 const and readonly Modifiers 218 const 218 readonly 219 Properties 220 Declaring a Property 221 Naming Conventions 224 Static Properties 225 Using Properties with Validation 225 Read-Only and Write-Only Properties 227 Access Modifiers on Getters and Setters 228 Properties as Virtual Fields 229 Properties and Method Calls Not Allowed as ref or out Parameter Values 232 Nested Classes 232 Partial Classes 234 6 Inheritance 237 Derivation 238 Casting between Base and Derived Types 241 Support for Parameter Covariance and Contravariance 243 private Access Modifier 244 protected Access Modifier 245 Single Inheritance 246 Sealed Classes 250 Overriding the Base Class 250 virtual Modifier 251 new Modifier 256 sealed Modifier 260 base Member 261 Constructors 262 Abstract Classes 263 Everything Ultimately Derives from System.Object 268 Verifying the Underlying Type with the is Operator 270 Conversion Using the as Operator 271 7 Interfaces 273 Introducing Interfaces 274 Polymorphism through Interfaces 275 Interface Implementation 279 Explicit Member Implementation 281 Implicit Member Implementation 282 Explicit versus Implicit Interface Implementation 283 Casting between the Implementing Class and Its Interfaces 284 Interface Inheritance 285 Multiple Interface Inheritance 287 Implementing Multiple Inheritance via Interfaces 288 Versioning 291 Interfaces Compared with Classes 293 8 Value Types 297 Structs 298 Initializing structs 302 Using the default Operator 304 Inheritance and Interfaces with Value Types 304 Boxing 305 Enums 311 Type Compatibility between Enums 315 Converting between Enums and Strings 315 Enums as Flags 316 9 Well-Formed Types 323 Overriding object Members 323 Overriding ToString() 324 Overriding GetHashCode() 324 Overriding Equals() 326 Guidelines for Implementing Equality 333 Operator Overloading 334 Comparison Operators (==, !=, , , =, =) 334 Binary Operators (+, -, *, /, %, &, |, ^, , ) 335 Combining Assignment with Binary Operators (+=, -=, *=, /=, %=, &=...) 337 Conditional Logical Operators (&&, ||) 337 Unary Operators (+, -, !, ~, ++, --, true, false) 338 Conversion Operators 339 Guidelines for Conversion Operators 340 Referencing Other Assemblies 341 Changing the Assembly Target 342 Encapsulation of Types 343 Referencing an Assembly 345 Defining Namespaces 346 Namespace Alias Qualifier 348 XML Comments 349 Associating XML Comments with Programming Constructs 350 Generating an XML Documentation File 352 Garbage Collection 353 Weak References 355 Resource Cleanup 356 Finalizers 357 Deterministic Finalization with the using Statement 359 Garbage Collection and Finalization 362 Resource Utilization and Finalization Guidelines 363 10 Exception Handling 365 Multiple Exception Types 365 Catching Exceptions 367 General Catch Block 368 Guidelines for Exception Handling 371 Defining Custom Exceptions 373 11 Generics 379 C# without Generics 380 Introducing Generic Types 385 Using a Generic Class 385 Defining a Simple Generic Class 387 Benefits of Generics 388 Type Parameter Naming Guidelines 389 Generic Interfaces and Structs 389 Defining a Constructor and a Finalizer 392 Specifying a Default Value 393 Multiple Type Parameters 394 Nested Generic Types 395 Type Compatibility between Generic Classes with Type-Compatible Type Parameters 396 Constraints 396 Interface Constraints 400 Base Class Constraints 401 struct/class Constraints 402 Multiple Constraints 403 Constructor Constraints 404 Constraint Inheritance 405 Generic Methods 409 Type Inferencing 411 Specifying Constraints 412 Generic Internals 413 Instantiating Generics Based on Value Types 415 Instantiating Generics Based on Reference Types 416 12 Collections 419 Primary Collection Classes 420 List Collections: List T and ArrayList 420 Dictionary Collections: Dictionary TKey, TValue and Hashtable 425 Sorted Collections: SortedDictionary TKey, TValue and SortedList T 429 Stack Collections: Stack T and Stack 431 Queue Collections: Queue T and Queue 432 Linked Lists: LinkedList T 433 Introducing Collection Class Interfaces 433 IList T versus IDictionary TKey, TValue 434 IComparable T 435 ICollection T 438 Iterating Using a foreach Loop 438 Providing an Index Operator 444 Returning Null or an Empty Collection 448 Iterators 448 Defining an Iterator 449 Iterator Syntax 450 Yielding Values from an Iterator 451 Iterators and State 453 More Iterator Examples 455 Placing a yield return within a Loop 456 Canceling Further Iteration: yield break 459 Creating Multiple Iterators in a Single Class 461 yield Statement Characteristics 462 13 Delegates and Events 465 Method Pointers 466 Defining the Scenario 466 Delegate Data Types 468 Delegate Internals 469 Defining a Delegate Type 470 Instantiating a Delegate 471 Anonymous Methods 475 Outer Variables 479 Multicast Delegates and the Observer Pattern 482 Coding the Observer Pattern with Delegates 482 Sequential Invocation 490 Events 496 Why Events? 496 Declaring an Event 498 Coding Conventions 500 Generics and Delegates 501 Customizing the Event Implementation 505 14 Reflection and Attributes 509 Refiection 510 Accessing Metadata Using System.Type 511 Member Invocation 513 Refiection on Generic Types 517 Attributes 520 Custom Attributes 524 Looking for Attributes 525 Initializing an Attribute through a Constructor 526 System.AttributeUsageAttribute 531 Named Parameters 532 15 Multithreading 549 Running and Controlling a Separate Thread 552 Starting a Thread 553 Thread Management 555 Passing Parameters to Threads 557 Thread Pooling 561 Unhandled Exceptions 563 Synchronization 565 Synchronization Using Monitor 568 Using the lock Keyword 570 Choosing a lock Object 571 Why to Avoid Locking on this and typeof(type) 572 Declaring Fields as volatile 573 Using the System.Threading.Interlocked Class 573 Event Notification with Multiple Threads 575 Synchronization Design Best Practices 576 More Synchronization Types 578 Timers 584 16 Multithreading Patterns 591 Asynchronous Results Pattern 592 Introducing the Asynchronous Results Pattern 593 Passing Data to and from an Alternate Thread 595 Receiving Notification of Thread Completion 600 Passing Arbitrary State 603 Asynchronous Results Conclusions 605 Background Worker Pattern 606 Establishing the Pattern 609 Exception Handling 610 Windows Forms 611 17 Platform Interoperability and Unsafe Code 615 Platform Invoke 616 Declaring External Functions 617 Parameter Data Types 618 Using ref Rather Than Pointers 619 Using StructLayoutAttribute for Sequential Layout 620 Error Handling 621 Using SafeHandle 623 Calling External Functions 626 Simplifying API Calls with Wrappers 628 Function Pointers Map to Delegates 629 Guidelines 629 Pointers and Addresses 630 Unsafe Code 630 Pointer Declaration 632 Assigning a Pointer 634 Dereferencing a Pointer 636 Accessing the Member of a Referent Type 638 18 The Common Language Infrastructure 641 Defining the Common Language Infrastructure (CLI) 642 CLI Implementations 643 C# Compilation to Machine Code 644 Runtime 647 Garbage Collection 647 Garbage Collection on .NET 648 Type Safety 649 Code Access Security 650 Platform Portability 650 Performance 651 Application Domains 652 Assemblies, Manifests, and Modules 653 Common Intermediate Language (CIL) 656 Common Type System (CTS) 656 Common Language Specification (CLS) 657 Base Class Library (BCL) 658 Metadata 658 A Downloading and Installing the C# Compiler and the CLI Platform 663 B Complete Source Code Listings 667 C C# 2.0 Topics 693 Index 697 |
序: |
|