Essential C# 12.0, 8th edition
BRAND: PEARSON
eBook edition. 1 Year Subscription. Dành cho Cá nhân | Trường ĐH, Nhóm, Thư Viện: Gọi 0915920514 để báo giá Pearson, Vital Source eBook hoặc mua Sách In
Tổng quan sách
Hướng dẫn toàn diện, chuyên nghiệp về C# 12.0 dành cho lập trình viên ở mọi cấp độĐược cập nhật cho bản phát hành Hỗ trợ dài hạn (LTS) của Microsoft C# 12.0, Essential C# 12.0 là một hướng dẫn C# được tổ chức tốt, không rườm rà, phù hợp với mọi lập trình viên. Dựa trên nội dung có giá trị cao đã được chứng minh của các phiên bản trước, chuyên gia C# đẳng cấp thế giới Mark Michaelis làm sáng tỏ những cải tiến chính trong C# 12, bao gồm bất kỳ loại bí danh nào, mảng nội tuyến, tham số biểu thức lambda mặc định, hỗ trợ mở rộng cho các hàm tạo chính và các phần chặn thử nghiệm.Michaelis trình bày hướng dẫn và tài liệu tham khảo toàn diện cho toàn bộ ngôn ngữ C# 12, giúp bạn đẩy nhanh hành trình trở thành lập trình viên C# cấp chuyên gia. Các ví dụ ngắn gọn minh họa các cấu trúc trung tâm và các nguyên tắc mã hóa hiện đại giúp bạn giảm thiểu lỗi và viết mã dễ phát triển hơn. Để giúp bạn nhanh chóng tìm thấy những gì bạn cần và duy trì khả năng tương thích, cuốn sách bao gồm các chỉ mục dành riêng cho phiên bản của các phiên bản C# gần đây cũng như các biểu tượng và ghi chú xác định thời điểm mỗi cải tiến được giới thiệu.
- Foreword xvPreface xviiAcknowledgments xxxiAbout the Author xxxiii
- Chapter 1: Introducing C# 1Hello, World 2C# Syntax Fundamentals 12Working with Variables 24Console Input and Output 28Managed Execution and the Common Language Infrastructure 38Multiple .NET Frameworks 44Summary 48
- Chapter 2: Data Types 49Type Name Forms 50Fundamental Numeric Types 52More Fundamental Types 63Conversions between Data Types 84Summary 92
- Chapter 3: More with Data Types 93Categories of Types 93Declaring Types That Allow null 96Implicitly Typed Local Variables 102Tuples 103Arrays 112Summary 134
- Chapter 4: Operators and Control Flow 137Operators 137Introducing Flow Control 156Code Blocks ({}) 161Code Blocks, Scopes, and Declaration Spaces 164Boolean Expressions 166Programming with null 173Bitwise Operators (, |, &, ^, ~) 181Control Flow Statements, Continued 187Jump Statements 200C# Preprocessor Directives 206Summary 215
- Chapter 5: Parameters and Methods 217Calling a Method 218Declaring a Method 225Local Functions 232Using Directives 233Returns and Parameters on Main Method 242Top-Level Statements 246Advanced Method Parameters 247Recursion 261Method Overloading 264Optional Parameters 267Basic Error Handling with Exceptions 272Summary 291
- Chapter 6: Classes 293Declaring and Instantiating a Class 298Instance Fields 302Instance Methods 305Using the this Keyword 306Access Modifiers 314Properties 316Constructors 333Non-Nullable Reference Type Properties with Constructors 346Nullable Attributes 354Deconstructors 357Static Members 359Extension Methods 370Encapsulating the Data 372Nested Classes 376Partial Classes 379Summary 384
- Chapter 7: Inheritance 385Derivation 386Overriding the Base Class 397Abstract Classes 410All Classes Derive from System.Object 417Type Checking 419Pattern Matching 423Avoid Pattern Matching When Polymorphism Is Possible 438Summary 440
- Chapter 8: Interfaces 443Introducing Interfaces 444Polymorphism through Interfaces 446Interface Implementation 451Converting between the Implementing Class and Its Interfaces 457Interface Inheritance 458Multiple Interface Inheritance 461Extension Methods on Interfaces 461Versioning 464Extension Methods versus Default Interface Members 480Interfaces Compared with Abstract Classes 482Interfaces Compared with Attributes 484Summary 484
- Chapter 9: Introducing Structs and Records 487Reference Equality versus Value Equality 493Structs 494Record Classes 500Record Class Inheritance 503Records 504Overriding object Members 513Customizing Record Behavior 521Boxing 523Enums 532Summary 544
- Chapter 10: Well-Formed Types 547Operator Overloading 548Referencing Other Assemblies 557Encapsulation of Types 564Defining Namespaces 567XML Comments 571Garbage Collection and Weak References 576Resource Cleanup 580Lazy Initialization 596Summary 598
- Chapter 11: Exception Handling 601Multiple Exception Types 601Catching Exceptions 604Rethrowing an Existing Exception 607General Catch Block 609Guidelines for Exception Handling 610Defining Custom Exceptions 614Rethrowing a Wrapped Exception 618Summary 622
- Chapter 12: Generics 623C# without Generics 624Introducing Generic Types 630Constraints 646Generic Methods 663Covariance and Contravariance 669Generic Internals 676Summary 681
- Chapter 13: Delegates and Lambda Expressions 683Introducing Delegates 684Declaring Delegate Types 688Lambda Expressions 698Statement Lambdas 699Expression Lambdas 702Anonymous Methods 705Delegates Do Not Have Structural Equality 707Outer Variables 710Static Anonymous Functions 712Expression Trees 716Summary 724
- Chapter 14: Events 727Coding the Publish–Subscribe Pattern with Multicast Delegates 728Understanding Events 743Summary 753
- Chapter 15: Collection Interfaces with Standard Query Operators 755Collection Initializers 756What Makes a Class a Collection: IEnumerable 759Standard Query Operators 766Anonymous Types with LINQ 796Summary 806
- Chapter 16: LINQ with Query Expressions 809Introducing Query Expressions 810Query Expressions Are Just Method Invocations 829Summary 831
- Chapter 17: Building Custom Collections 833More Collection Interfaces 834Primary Collection Classes 837Providing an Indexer 859Returning null or an Empty Collection 862Iterators 863Summary 879
- Chapter 18: Reflection, Attributes, and Dynamic Programming 881Reflection 881nameof Operator 894Attributes 895Programming with Dynamic Objects 920Summary 931
- Chapter 19: Introducing Multithreading 933Multithreading Basics 935Asynchronous Tasks 943Canceling a Task 965Working with System.Threading 972Summary 973
- Chapter 20: Programming the Task-Based Asynchronous Pattern 975Synchronously Invoking a High-Latency Operation 975Asynchronously Invoking a High-Latency Operation Using the TPL 979The Task-Based Asynchronous Pattern with async and await 984Introducing Asynchronous Return of ValueTask 991Asynchronous Streams 994IAsyncDisposable and the await using Declaration and Statement 998Using LINQ with IAsyncEnumerable 999Returning void from an Asynchronous Method 1001Asynchronous Lambdas and Local Functions 1006Task Schedulers and the Synchronization Context 1013async/await with the Windows UI 1015Summary 1019
- Chapter 21: Iterating in Parallel 1021Executing Loop Iterations in Parallel 1021Running LINQ Queries in Parallel 1032Summary 1039
- Chapter 22: Thread Synchronization 1041Why Synchronization? 1042Timers 1073Summary 1076
- Chapter 23: Platform Interoperability and Unsafe Code 1077Platform Invoke 1078Pointers and Addresses 1093Executing Unsafe Code via a Delegate 1104Summary 1105
- Chapter 24: The Common Language Infrastructure 1107Defining the Common Language Infrastructure 1107CLI Implementations 1109.NET Standard 1113Base Class Library 1113C# Compilation to Machine Code 1114Runtime 1116Assemblies, Manifests, and Modules 1121Common Intermediate Language 1124Common Type System 1125Common Language Specification 1125Metadata 1126.NET Native and Ahead of Time Compilation 1127Summary 1128Index 1131Index of 8.0 Topics 1187Index of 9.0 Topics 1190Index of 10.0 Topics 1191Index of 11.0 Topics 1192Index of 12.0 Topics 1193
