实例介绍
【实例简介】
【实例截图】
【核心代码】
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. Introducing C# and the .NET Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Object Orientation 1 Type Safety 2 Memory Management 3 Platform Support 3 C# and the CLR 3 The CLR and .NET Framework 4 Other Frameworks 5 A Brief History of C# 8 2. C# Language Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 A First C# Program 15 Syntax 18 Type Basics 21 Numeric Types 30 Boolean Type and Operators 37 Strings and Characters 39 Arrays 42 Variables and Parameters 46 Expressions and Operators 56 Null Operators 60 Statements 62 Namespaces 71 3. Creating Types in C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Classes 79 Inheritance 96 The object Type 105 iii Structs 109 Access Modifiers 110 Interfaces 112 Enums 118 Nested Types 121 Generics 122 4. Advanced C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Delegates 137 Events 146 Lambda Expressions 153 Anonymous Methods 158 try Statements and Exceptions 158 Enumeration and Iterators 167 Nullable Types 173 Extension Methods 179 Anonymous Types 181 Tuples (C# 7) 183 Attributes 186 Caller Info Attributes 188 Dynamic Binding 190 Operator Overloading 198 Unsafe Code and Pointers 201 Preprocessor Directives 205 XML Documentation 207 5. Framework Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 .NET Standard 2.0 215 The CLR and Core Framework 217 Applied Technologies 221 6. Framework Fundamentals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 String and Text Handling 229 Dates and Times 243 Dates and Time Zones 250 Formatting and Parsing 256 Standard Format Strings and Parsing Flags 262 Other Conversion Mechanisms 269 Globalization 273 Working with Numbers 275 Enums 278 The Guid Struct 282 iv | Table of Contents Equality Comparison 282 Order Comparison 293 Utility Classes 296 7. Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 Enumeration 301 The ICollection and IList Interfaces 309 The Array Class 313 Lists, Queues, Stacks, and Sets 321 Dictionaries 330 Customizable Collections and Proxies 336 Plugging in Equality and Order 343 8. LINQ Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 Getting Started 351 Fluent Syntax 353 Query Expressions 360 Deferred Execution 364 Subqueries 370 Composition Strategies 373 Projection Strategies 377 Interpreted Queries 379 LINQ to SQL and Entity Framework 386 Building Query Expressions 400 9. LINQ Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 Overview 409 Filtering 412 Projecting 416 Joining 428 Ordering 436 Grouping 439 Set Operators 442 Conversion Methods 443 Element Operators 446 Aggregation Methods 448 Quantifiers 453 Generation Methods 454 10. LINQ to XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 Architectural Overview 455 X-DOM Overview 456 Table of Contents | v Instantiating an X-DOM 460 Navigating and Querying 462 Updating an X-DOM 467 Working with Values 470 Documents and Declarations 473 Names and Namespaces 477 Annotations 482 Projecting into an X-DOM 483 11. Other XML Technologies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 XmlReader 491 XmlWriter 501 Patterns for Using XmlReader/XmlWriter 503 XSD and Schema Validation 507 XSLT 510 12. Disposal and Garbage Collection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 IDisposable, Dispose, and Close 513 Automatic Garbage Collection 519 Finalizers 521 How the Garbage Collector Works 526 Managed Memory Leaks 530 Weak References 534 13. Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539 Conditional Compilation 539 Debug and Trace Classes 543 Debugger Integration 546 Processes and Process Threads 547 StackTrace and StackFrame 548 Windows Event Logs 550 Performance Counters 553 The Stopwatch Class 558 14. Concurrency and Asynchrony. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 Introduction 559 Threading 560 Tasks 577 Principles of Asynchrony 585 Asynchronous Functions in C# 590 Asynchronous Patterns 606 Obsolete Patterns 614 vi | Table of Contents 15. Streams and I/O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 Stream Architecture 617 Using Streams 619 Stream Adapters 633 Compression Streams 641 Working with ZIP Files 643 File and Directory Operations 644 File I/O in UWP 654 Memory-Mapped Files 657 Isolated Storage 659 16. Networking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 Network Architecture 661 Addresses and Ports 664 URIs 665 Client-Side Classes 667 Working with HTTP 680 Writing an HTTP Server 686 Using FTP 689 Using DNS 691 Sending Mail with SmtpClient 692 Using TCP 692 Receiving POP3 Mail with TCP 696 TCP in Windows Runtime 698 17. Serialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701 Serialization Concepts 701 The Data Contract Serializer 705 Data Contracts and Collections 715 Extending Data Contracts 717 The Binary Serializer 721 Binary Serialization Attributes 723 Binary Serialization with ISerializable 726 XML Serialization 730 18. Assemblies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741 What’s in an Assembly 741 Strong Names and Assembly Signing 746 Assembly Names 749 Authenticode Signing 752 The Global Assembly Cache 755 Resources and Satellite Assemblies 758 Table of Contents | vii Resolving and Loading Assemblies 766 Deploying Assemblies Outside the Base Folder 772 Packing a Single-File Executable 773 Working with Unreferenced Assemblies 774 19. Reflection and Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 Reflecting and Activating Types 778 Reflecting and Invoking Members 785 Reflecting Assemblies 798 Working with Attributes 799 Dynamic Code Generation 805 Emitting Assemblies and Types 812 Emitting Type Members 816 Emitting Generic Methods and Types 822 Awkward Emission Targets 824 Parsing IL 827 20. Dynamic Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833 The Dynamic Language Runtime 833 Numeric Type Unification 835 Dynamic Member Overload Resolution 836 Implementing Dynamic Objects 842 Interoperating with Dynamic Languages 845 21. Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849 Code Access Security 849 Identity and Role Security 850 Operating System Security 853 Cryptography Overview 856 Windows Data Protection 856 Hashing 857 Symmetric Encryption 859 Public Key Encryption and Signing 863 22. Advanced Threading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869 Synchronization Overview 870 Exclusive Locking 870 Locking and Thread Safety 878 Nonexclusive Locking 884 Signaling with Event Wait Handles 889 The Barrier Class 898 Lazy Initialization 899 viii | Table of Contents Thread-Local Storage 902 Interrupt and Abort 904 Suspend and Resume 905 Timers 906 23. Parallel Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911 Why PFX? 911 PLINQ 915 The Parallel Class 928 Task Parallelism 934 Working with AggregateException 944 Concurrent Collections 946 BlockingCollection<T> 949 24. Application Domains. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 953 Application Domain Architecture 953 Creating and Destroying Application Domains 954 Using Multiple Application Domains 956 Using DoCallBack 958 Monitoring Application Domains 959 Domains and Threads 959 Sharing Data Between Domains 961 25. Native and COM Interoperability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 967 Calling into Native DLLs 967 Type Marshaling 968 Callbacks from Unmanaged Code 971 Simulating a C Union 971 Shared Memory 972 Mapping a Struct to Unmanaged Memory 975 COM Interoperability 979 Calling a COM Component from C# 981 Embedding Interop Types 984 Primary Interop Assemblies 985 Exposing C# Objects to COM 986 26. Regular Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987 Regular Expression Basics 988 Quantifiers 992 Zero-Width Assertions 993 Groups 996 Replacing and Splitting Text 997 Table of Contents | ix Cookbook Regular Expressions 999 Regular Expressions Language Reference 1003 27. The Roslyn Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1007 Roslyn Architecture 1008 Syntax Trees 1009 Compilations and Semantic Models 1024 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1037
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论