Tài Liệu Lập Trình C# 6.0

1.1K 506 0
Tài Liệu Lập Trình C# 6.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

on & i t i i l e r Ed T p h NE om 6t r s y n C ve s l Co e Ro th C# in a Nutshell THE DEFINITIVE REFERENCE Joseph Albahari & Ben Albahari C# 6.0 in a Nutshell When you have questions about C# 6.0 or the NET CLR and its core Framework assemblies, this bestselling guide has the answers you need C# has become a language of unusual flexibility and breadth since its premiere in 2000, but this continual growth means there’s still much more to learn O rg a n ize d a ro u n d co n ce pt s a n d u s e c a s e s , this thoroughly updated sixth edition provides intermediate and advanced programmers with a concise map of C# and NET knowledge Dive in and discover why this Nutshell guide is considered the definitive reference on C# ■■ Get up to speed with all aspects of the C# language, from the basics of syntax and variables, to advanced topics such as pointers and operator overloading ■■ Dig deep into LINQ via three chapters dedicated to the topic ■■ Learn about dynamic, asynchronous, and parallel programming ■■ Work with NET features, including XML, networking, serialization, reflection, security, application domains, and code contracts ■■ Explore the new C# 6.0 compiler-as-aservice, Roslyn I keep on my desk as a quick reference ” —Scott Guthrie Microsoft and experts “ Novices alike will find the latest techniques in C# programming here ” —Eric Lippert C# MVP Joseph Albahari, author of C# 5.0 in a Nutshell, C# 5.0 Pocket Reference, and LINQ Pocket Reference, also wrote LINQPad, the popular code scratchpad and LINQ querying utility Ben Albahari, a former program manager at Microsoft, is cofounder of Auditionist, a casting website for actors in the UK Twitter: @oreillymedia facebook.com/oreilly C#/MICROSOF T NET US $59.99 6.0 in a Nutshell is “ C# one of the few books CAN $68.99 ISBN: 978-1-491-92706-9 C# 6.0 IN A NUTSHELL Joseph Albahari & Ben Albahari C# 6.0 in a Nutshell by Joseph Albahari and Ben Albahari Copyright © 2016 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://safaribooksonline.com) For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com Editor: Brian MacDonald Production Editor: Kristen Brown Proofreader: Amanda Kersey Indexer: Angela Howard December 2015: Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest Sixth Edition Revision History for the Sixth Edition 2015-11-03: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491927069 for release details The O’Reilly logo is a registered trademark of O’Reilly Media, Inc C# 6.0 in a Nutshell, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc While the publisher and the authors have used good faith efforts to ensure that the informa‐ tion and instructions contained in this work are accurate, the publisher and the authors dis‐ claim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work Use of the information and instructions contained in this work is at your own risk If any code samples or other technol‐ ogy this work contains or describes is subject to open source licenses or the intellectual prop‐ erty rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights 978-1-491-92706-9 [M] 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# 6.0 What Was New in C# 5.0 What Was New in C# 4.0 What Was New in C# 3.0 3 3 8 C# Language Basics 11 A First C# Program Syntax Type Basics Numeric Types Boolean Type and Operators Strings and Characters Arrays Variables and Parameters Expressions and Operators Null Operators Statements Namespaces 11 14 17 26 33 35 38 42 51 55 56 65 Creating Types in C# 73 iii Classes Inheritance The object Type Structs Access Modifiers Interfaces Enums Nested Types Generics 73 88 97 101 102 104 109 113 114 Advanced C# 127 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 127 136 143 147 148 156 162 168 171 174 175 183 185 187 190 193 Framework Overview 199 The CLR and Core Framework Applied Technologies 202 206 Framework Fundamentals 213 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 iv | Table of Contents 213 226 234 240 246 253 257 258 262 Tuples The Guid Struct Equality Comparison Order Comparison Utility Classes 266 267 267 278 281 Collections 285 Enumeration The ICollection and IList Interfaces The Array Class Lists, Queues, Stacks, and Sets Dictionaries Customizable Collections and Proxies Plugging in Equality and Order 285 293 297 305 314 321 327 LINQ Queries 335 Getting Started Fluent Syntax Query Expressions Deferred Execution Subqueries Composition Strategies Projection Strategies Interpreted Queries LINQ to SQL and Entity Framework Building Query Expressions 335 337 344 348 355 358 362 364 371 385 LINQ Operators 391 Overview Filtering Projecting Joining Ordering Grouping Set Operators Conversion Methods Element Operators Aggregation Methods Quantifiers Generation Methods 393 396 400 412 420 423 426 427 430 432 437 438 10 LINQ to XML 441 Table of Contents | v Architectural Overview X-DOM Overview Instantiating an X-DOM Navigating and Querying Updating an X-DOM Working with Values Documents and Declarations Names and Namespaces Annotations Projecting into an X-DOM 441 442 446 448 453 456 459 463 468 469 11 Other XML Technologies 477 XmlReader XmlWriter Patterns for Using XmlReader/XmlWriter XSD and Schema Validation XSLT 478 487 489 493 496 12 Disposal and Garbage Collection 499 IDisposable, Dispose, and Close Automatic Garbage Collection Finalizers How the Garbage Collector Works Managed Memory Leaks Weak References 499 505 507 512 516 520 13 Diagnostics and Code Contracts 525 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 vi | Table of Contents 525 529 532 537 541 543 545 546 548 549 551 552 553 555 557 The Stopwatch Class 562 14 Concurrency and Asynchrony 563 Introduction Threading Tasks Principles of Asynchrony Asynchronous Functions in C# Asynchronous Patterns Obsolete Patterns 563 564 581 589 594 610 618 15 Streams and I/O 623 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 623 625 639 647 649 650 661 663 666 16 Networking 673 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 673 675 676 679 692 698 701 703 703 704 708 709 17 Serialization 713 Serialization Concepts The Data Contract Serializer Data Contracts and Collections Extending Data Contracts The Binary Serializer 713 717 727 730 733 Table of Contents | vii Binary Serialization Attributes Binary Serialization with ISerializable XML Serialization 735 738 742 18 Assemblies 753 What’s in an Assembly Strong Names and Assembly Signing Assembly Names Authenticode Signing 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 753 758 761 764 768 770 779 784 785 787 19 Reflection and Metadata 789 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 790 797 810 812 818 825 828 834 836 840 20 Dynamic Programming 847 The Dynamic Language Runtime Numeric Type Unification Dynamic Member Overload Resolution Implementing Dynamic Objects Interoperating with Dynamic Languages 847 849 850 856 859 21 Security 863 Permissions Code Access Security (CAS) Allowing Partially Trusted Callers The Transparency Model Sandboxing Another Assembly Operating System Security viii | Table of Contents 863 868 871 873 881 885 ... facebook.com/oreilly C#/ MICROSOF T NET US $59.99 6.0 in a Nutshell is “ C# one of the few books CAN $68.99 ISBN: 978-1-491-92706-9 C# 6.0 IN A NUTSHELL Joseph Albahari & Ben Albahari C# 6.0 in a Nutshell... Runtime What’s New in C# 6.0 What Was New in C# 5.0 What Was New in C# 4.0 What Was New in C# 3.0 3 3 8 C# Language Basics 11 A First C# Program Syntax.. .C# 6.0 in a Nutshell When you have questions about C# 6.0 or the NET CLR and its core Framework assemblies, this bestselling guide has the answers you need C# has become a language

Ngày đăng: 15/05/2018, 18:25

Từ khóa liên quan

Mục lục

  • Copyright

  • Table of Contents

  • Preface

    • Intended Audience

    • How This Book Is Organized

    • What You Need to Use This Book

    • Conventions Used in This Book

    • Using Code Examples

    • Safari® Books Online

    • How to Contact Us

    • Acknowledgments

      • Joseph Albahari

      • Ben Albahari

      • Chapter 1. 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# 6.0

        • What Was New in C# 5.0

Tài liệu cùng người dùng

Tài liệu liên quan