1. Trang chủ
  2. » Công Nghệ Thông Tin

C 5 0 in a nutshell, 5th edition

1,1K 149 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.062
Dung lượng 12,19 MB

Nội dung

www.it-ebooks.info www.it-ebooks.info C# 5.0 IN A NUTSHELL Fifth Edition Joseph Albahari and Ben Albahari Beijing • Cambridge • Farnham • Kưln • Sebastopol • Tokyo www.it-ebooks.info C# 5.0 in a Nutshell, Fifth Edition by Joseph Albahari and Ben Albahari Copyright © 2012 Joseph Albahari and Ben Albahari All rights reserved Printed in the United States of America Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safaribooksonline.com) For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com Editor: Rachel Roumeliotis Production Editor: Melanie Yarbrough Copyeditor: Nancy Reinhardt Proofreader: Jennifer Knight June 2012: Indexer: Jay Marchand Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Fifth Edition Revision History for the Fifth Edition: 2012-06-08 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449320102 for release details Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc C# 5.0 in a Nutshell, the cover image of a numidian crane, and related trade dress are trademarks of O’Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN: 978-1-449-32010-2 [M] 1340210346 www.it-ebooks.info Table of Contents Preface xi Introducing C# and the NET Framework Object Orientation Type Safety Memory Management Platform Support C#’s Relationship with the CLR The CLR and NET Framework C# and Windows Runtime What’s New in C# 5.0 What’s New in C# 4.0 What’s New in C# 3.0 2 3 6 C# Language Basics A First C# Program Syntax Type Basics Numeric Types Boolean Type and Operators Strings and Characters Arrays Variables and Parameters Expressions and Operators Statements Namespaces 12 15 23 30 32 34 38 47 51 59 iii www.it-ebooks.info Creating Types in C# 67 Classes Inheritance The object Type Structs Access Modifiers Interfaces Enums Nested Types Generics 67 80 89 93 94 96 102 105 106 Advanced C# 119 Delegates Events Lambda Expressions Anonymous Methods try Statements and Exceptions Enumeration and Iterators Nullable Types Operator Overloading Extension Methods Anonymous Types Dynamic Binding Attributes Caller Info Attributes (C# 5) Unsafe Code and Pointers Preprocessor Directives XML Documentation 119 128 135 139 140 148 153 158 162 164 165 173 175 177 180 182 Framework Overview 187 The CLR and Core Framework Applied Technologies 189 194 Framework Fundamentals 201 String and Text Handling Dates and Times Dates and Time Zones Formatting and Parsing Standard Format Strings and Parsing Flags Other Conversion Mechanisms Globalization Working with Numbers Enums Tuples The Guid Struct iv | Table of Contents www.it-ebooks.info 201 214 221 227 233 240 244 245 249 252 253 Equality Comparison Order Comparison Utility Classes 254 264 267 Collections 271 Enumeration The ICollection and IList Interfaces The Array Class Lists, Queues, Stacks, and Sets Dictionaries Customizable Collections and Proxies Plugging in Equality and Order 271 279 282 291 299 306 312 LINQ Queries 319 Getting Started Fluent Syntax Query Expressions Deferred Execution Subqueries Composition Strategies Projection Strategies Interpreted Queries LINQ to SQL and Entity Framework Building Query Expressions 319 321 328 332 338 342 345 347 354 368 LINQ Operators 375 Overview Filtering Projecting Joining Ordering Grouping Set Operators Conversion Methods Element Operators Aggregation Methods Quantifiers Generation Methods 377 379 383 395 403 406 409 410 413 415 419 420 10 LINQ to XML 423 Architectural Overview X-DOM Overview Instantiating an X-DOM Navigating and Querying Updating an X-DOM 423 424 427 430 435 Table of Contents | v www.it-ebooks.info Working with Values Documents and Declarations Names and Namespaces Annotations Projecting into an X-DOM 438 441 444 450 450 11 Other XML Technologies 457 XmlReader XmlWriter Patterns for Using XmlReader/XmlWriter XmlDocument XPath XSD and Schema Validation XSLT 458 467 469 473 477 481 484 12 Disposal and Garbage Collection 485 IDisposable, Dispose, and Close Automatic Garbage Collection Finalizers How the Garbage Collector Works Managed Memory Leaks Weak References 485 490 493 497 501 505 13 Diagnostics and Code Contracts 509 Conditional Compilation Debug and Trace Classes Code Contracts Overview Preconditions Postconditions Assertions and Object Invariants Contracts on Interfaces and Abstract Methods Dealing with Contract Failure Selectively Enforcing Contracts Static Contract Checking Debugger Integration Processes and Process Threads StackTrace and StackFrame Windows Event Logs Performance Counters The Stopwatch Class 509 512 516 520 524 527 528 529 531 533 535 536 537 538 541 545 14 Concurrency & Asynchrony 547 Introduction Threading Tasks 547 548 565 vi | Table of Contents www.it-ebooks.info Principles of Asynchrony Asynchronous Functions in C# 5.0 Asynchronous Patterns Obsolete Patterns 573 578 594 601 15 Streams and I/O 605 Stream Architecture Using Streams Stream Adapters Compression Streams Working with Zip Files File and Directory Operations File I/O in Windows Runtime Memory-Mapped Files Isolated Storage 605 607 621 629 631 632 642 644 647 16 Networking 653 Network Architecture Addresses and Ports URIs Client-Side Classes Working with HTTP Writing an HTTP Server Using FTP Using DNS Sending Mail with SmtpClient Using TCP Receiving POP3 Mail with TCP TCP in Windows Runtime 653 655 656 658 671 677 680 682 683 683 687 689 17 Serialization 691 Serialization Concepts The Data Contract Serializer Data Contracts and Collections Extending Data Contracts The Binary Serializer Binary Serialization Attributes Binary Serialization with ISerializable XML Serialization 691 695 705 707 710 712 715 719 18 Assemblies 729 What’s in an Assembly Strong Names and Assembly Signing Assembly Names Authenticode Signing 729 734 737 739 Table of Contents | vii www.it-ebooks.info The Global Assembly Cache Resources and Satellite Assemblies Resolving and Loading Assemblies Deploying Assemblies Outside the Base Folder Packing a Single-File Executable Working with Unreferenced Assemblies 743 745 754 759 760 762 19 Reflection and Metadata 765 Reflecting and Activating Types Reflecting and Invoking Members Reflecting Assemblies Working with Attributes Dynamic Code Generation Emitting Assemblies and Types Emitting Type Members Emitting Generic Methods and Types Awkward Emission Targets Parsing IL 766 773 785 786 792 799 803 808 810 814 20 Dynamic Programming 821 The Dynamic Language Runtime Numeric Type Unification Dynamic Member Overload Resolution Implementing Dynamic Objects Interoperating with Dynamic Languages 821 823 824 830 833 21 Security 837 Permissions Code Access Security (CAS) Allowing Partially Trusted Callers The Transparency Model Sandboxing Another Assembly Operating System Security Identity and Role Security Cryptography Overview Windows Data Protection Hashing Symmetric Encryption Public Key Encryption and Signing 837 842 845 847 855 858 861 862 863 864 865 870 22 Advanced Threading 875 Synchronization Overview Exclusive Locking Locking and Thread Safety Non-Exclusive Locking viii | Table of Contents www.it-ebooks.info 876 876 884 890 ... 957 Application Domain Architecture Creating and Destroying Application Domains Using Multiple Application Domains Using DoCallBack Monitoring Application Domains Domains and Threads Sharing... on Interfaces and Abstract Methods Dealing with Contract Failure Selectively Enforcing Contracts Static Contract Checking Debugger Integration Processes and Process Threads StackTrace and StackFrame... listings for Chapter through Chapter 10, plus the chapters on concurrency, parallel programming, and dynamic programming are available as interactive (editable) LINQPad samples You can download

Ngày đăng: 12/03/2019, 10:11

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN