Cart

Essential C# 12.0, 8th edition

BRAND: PEARSON

Publisher:Addison-Wesley Professional
Author: Mark Michaelis
Edition: (December 26, 2023) © 2024
eBook ISBN:9780138219437
Print ISBN: 9780138219512
Type: 1 Year Subscription. Dành cho Cá nhân  

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  

Số lượng:
Tổng tiền:
Giá có thể thay đổi bất kỳ khi nào.
Thời hạn giao hàng: 03 ngày làm việc với sách eBook và 30 ngày với sách In. Gọi để được Tư vấn Giáo Trình.

Mô tả sản phẩm


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 xv

Preface xvii

Acknowledgments xxxi

About the Author xxxiii

Chapter 1: Introducing C# 1

Hello, World 2
C# Syntax Fundamentals 12
Working with Variables 24
Console Input and Output 28
Managed Execution and the Common Language Infrastructure 38
Multiple .NET Frameworks 44
Summary 48

Chapter 2: Data Types 49

Type Name Forms 50
Fundamental Numeric Types 52
More Fundamental Types 63
Conversions between Data Types 84
Summary 92

Chapter 3: More with Data Types 93

Categories of Types 93
Declaring Types That Allow null 96
Implicitly Typed Local Variables 102
Tuples 103
Arrays 112
Summary 134

Chapter 4: Operators and Control Flow 137

Operators 137
Introducing Flow Control 156
Code Blocks ({}) 161
Code Blocks, Scopes, and Declaration Spaces 164
Boolean Expressions 166
Programming with null 173
Bitwise Operators (<<, >>, |, &, ^, ~) 181
Control Flow Statements, Continued 187
Jump Statements 200
C# Preprocessor Directives 206
Summary 215

Chapter 5: Parameters and Methods 217

Calling a Method 218
Declaring a Method 225
Local Functions 232
Using Directives 233
Returns and Parameters on Main Method 242
Top-Level Statements 246
Advanced Method Parameters 247
Recursion 261
Method Overloading 264
Optional Parameters 267
Basic Error Handling with Exceptions 272
Summary 291

Chapter 6: Classes 293

Declaring and Instantiating a Class 298
Instance Fields 302
Instance Methods 305
Using the this Keyword 306
Access Modifiers 314
Properties 316
Constructors 333
Non-Nullable Reference Type Properties with Constructors 346
Nullable Attributes 354
Deconstructors 357
Static Members 359
Extension Methods 370
Encapsulating the Data 372
Nested Classes 376
Partial Classes 379
Summary 384

Chapter 7: Inheritance 385

Derivation 386
Overriding the Base Class 397
Abstract Classes 410
All Classes Derive from System.Object 417
Type Checking 419
Pattern Matching 423
Avoid Pattern Matching When Polymorphism Is Possible 438
Summary 440

Chapter 8: Interfaces 443

Introducing Interfaces 444
Polymorphism through Interfaces 446
Interface Implementation 451
Converting between the Implementing Class and Its Interfaces 457
Interface Inheritance 458
Multiple Interface Inheritance 461
Extension Methods on Interfaces 461
Versioning 464
Extension Methods versus Default Interface Members 480
Interfaces Compared with Abstract Classes 482
Interfaces Compared with Attributes 484
Summary 484

Chapter 9: Introducing Structs and Records 487

Reference Equality versus Value Equality 493
Structs 494
Record Classes 500
Record Class Inheritance 503
Records 504
Overriding object Members 513
Customizing Record Behavior 521
Boxing 523
Enums 532
Summary 544

Chapter 10: Well-Formed Types 547

Operator Overloading 548
Referencing Other Assemblies 557
Encapsulation of Types 564
Defining Namespaces 567
XML Comments 571
Garbage Collection and Weak References 576
Resource Cleanup 580
Lazy Initialization 596
Summary 598

Chapter 11: Exception Handling 601

Multiple Exception Types 601
Catching Exceptions 604
Rethrowing an Existing Exception 607
General Catch Block 609
Guidelines for Exception Handling 610
Defining Custom Exceptions 614
Rethrowing a Wrapped Exception 618
Summary 622

Chapter 12: Generics 623

C# without Generics 624
Introducing Generic Types 630
Constraints 646
Generic Methods 663
Covariance and Contravariance 669
Generic Internals 676
Summary 681

Chapter 13: Delegates and Lambda Expressions 683

Introducing Delegates 684
Declaring Delegate Types 688
Lambda Expressions 698
Statement Lambdas 699
Expression Lambdas 702
Anonymous Methods 705
Delegates Do Not Have Structural Equality 707
Outer Variables 710
Static Anonymous Functions 712
Expression Trees 716
Summary 724

Chapter 14: Events 727

Coding the Publish–Subscribe Pattern with Multicast Delegates 728
Understanding Events 743
Summary 753

Chapter 15: Collection Interfaces with Standard Query Operators 755

Collection Initializers 756
What Makes a Class a Collection: IEnumerable 759
Standard Query Operators 766
Anonymous Types with LINQ 796
Summary 806

Chapter 16: LINQ with Query Expressions 809

Introducing Query Expressions 810
Query Expressions Are Just Method Invocations 829
Summary 831

Chapter 17: Building Custom Collections 833

More Collection Interfaces 834
Primary Collection Classes 837
Providing an Indexer 859
Returning null or an Empty Collection 862
Iterators 863
Summary 879

Chapter 18: Reflection, Attributes, and Dynamic Programming 881

Reflection 881
nameof Operator 894
Attributes 895
Programming with Dynamic Objects 920
Summary 931

Chapter 19: Introducing Multithreading 933

Multithreading Basics 935
Asynchronous Tasks 943
Canceling a Task 965
Working with System.Threading 972
Summary 973

Chapter 20: Programming the Task-Based Asynchronous Pattern 975

Synchronously Invoking a High-Latency Operation 975
Asynchronously Invoking a High-Latency Operation Using the TPL 979
The Task-Based Asynchronous Pattern with async and await 984
Introducing Asynchronous Return of ValueTask<T> 991
Asynchronous Streams 994
IAsyncDisposable and the await using Declaration and Statement 998
Using LINQ with IAsyncEnumerable 999
Returning void from an Asynchronous Method 1001
Asynchronous Lambdas and Local Functions 1006
Task Schedulers and the Synchronization Context 1013
async/await with the Windows UI 1015
Summary 1019

Chapter 21: Iterating in Parallel 1021

Executing Loop Iterations in Parallel 1021
Running LINQ Queries in Parallel 1032
Summary 1039

Chapter 22: Thread Synchronization 1041

Why Synchronization? 1042
Timers 1073
Summary 1076

Chapter 23: Platform Interoperability and Unsafe Code 1077

Platform Invoke 1078
Pointers and Addresses 1093
Executing Unsafe Code via a Delegate 1104
Summary 1105

Chapter 24: The Common Language Infrastructure 1107

Defining the Common Language Infrastructure 1107
CLI Implementations 1109
.NET Standard 1113
Base Class Library 1113
C# Compilation to Machine Code 1114
Runtime 1116
Assemblies, Manifests, and Modules 1121
Common Intermediate Language 1124
Common Type System 1125
Common Language Specification 1125
Metadata 1126
.NET Native and Ahead of Time Compilation 1127
Summary 1128

Index 1131

Index of 8.0 Topics 1187

Index of 9.0 Topics 1190

Index of 10.0 Topics 1191

Index of 11.0 Topics 1192

Index of 12.0 Topics 1193

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.

MỤC LỤC

Foreword xv

Preface xvii

Acknowledgments xxxi

About the Author xxxiii

Chapter 1: Introducing C# 1

Hello, World 2
C# Syntax Fundamentals 12
Working with Variables 24
Console Input and Output 28
Managed Execution and the Common Language Infrastructure 38
Multiple .NET Frameworks 44
Summary 48

Chapter 2: Data Types 49

Type Name Forms 50
Fundamental Numeric Types 52
More Fundamental Types 63
Conversions between Data Types 84
Summary 92

Chapter 3: More with Data Types 93

Categories of Types 93
Declaring Types That Allow null 96
Implicitly Typed Local Variables 102
Tuples 103
Arrays 112
Summary 134

Chapter 4: Operators and Control Flow 137

Operators 137
Introducing Flow Control 156
Code Blocks ({}) 161
Code Blocks, Scopes, and Declaration Spaces 164
Boolean Expressions 166
Programming with null 173
Bitwise Operators (<<, >>, |, &, ^, ~) 181
Control Flow Statements, Continued 187
Jump Statements 200
C# Preprocessor Directives 206
Summary 215

Chapter 5: Parameters and Methods 217

Calling a Method 218
Declaring a Method 225
Local Functions 232
Using Directives 233
Returns and Parameters on Main Method 242
Top-Level Statements 246
Advanced Method Parameters 247
Recursion 261
Method Overloading 264
Optional Parameters 267
Basic Error Handling with Exceptions 272
Summary 291

Chapter 6: Classes 293

Declaring and Instantiating a Class 298
Instance Fields 302
Instance Methods 305
Using the this Keyword 306
Access Modifiers 314
Properties 316
Constructors 333
Non-Nullable Reference Type Properties with Constructors 346
Nullable Attributes 354
Deconstructors 357
Static Members 359
Extension Methods 370
Encapsulating the Data 372
Nested Classes 376
Partial Classes 379
Summary 384

Chapter 7: Inheritance 385

Derivation 386
Overriding the Base Class 397
Abstract Classes 410
All Classes Derive from System.Object 417
Type Checking 419
Pattern Matching 423
Avoid Pattern Matching When Polymorphism Is Possible 438
Summary 440

Chapter 8: Interfaces 443

Introducing Interfaces 444
Polymorphism through Interfaces 446
Interface Implementation 451
Converting between the Implementing Class and Its Interfaces 457
Interface Inheritance 458
Multiple Interface Inheritance 461
Extension Methods on Interfaces 461
Versioning 464
Extension Methods versus Default Interface Members 480
Interfaces Compared with Abstract Classes 482
Interfaces Compared with Attributes 484
Summary 484

Chapter 9: Introducing Structs and Records 487

Reference Equality versus Value Equality 493
Structs 494
Record Classes 500
Record Class Inheritance 503
Records 504
Overriding object Members 513
Customizing Record Behavior 521
Boxing 523
Enums 532
Summary 544

Chapter 10: Well-Formed Types 547

Operator Overloading 548
Referencing Other Assemblies 557
Encapsulation of Types 564
Defining Namespaces 567
XML Comments 571
Garbage Collection and Weak References 576
Resource Cleanup 580
Lazy Initialization 596
Summary 598

Chapter 11: Exception Handling 601

Multiple Exception Types 601
Catching Exceptions 604
Rethrowing an Existing Exception 607
General Catch Block 609
Guidelines for Exception Handling 610
Defining Custom Exceptions 614
Rethrowing a Wrapped Exception 618
Summary 622

Chapter 12: Generics 623

C# without Generics 624
Introducing Generic Types 630
Constraints 646
Generic Methods 663
Covariance and Contravariance 669
Generic Internals 676
Summary 681

Chapter 13: Delegates and Lambda Expressions 683

Introducing Delegates 684
Declaring Delegate Types 688
Lambda Expressions 698
Statement Lambdas 699
Expression Lambdas 702
Anonymous Methods 705
Delegates Do Not Have Structural Equality 707
Outer Variables 710
Static Anonymous Functions 712
Expression Trees 716
Summary 724

Chapter 14: Events 727

Coding the Publish–Subscribe Pattern with Multicast Delegates 728
Understanding Events 743
Summary 753

Chapter 15: Collection Interfaces with Standard Query Operators 755

Collection Initializers 756
What Makes a Class a Collection: IEnumerable 759
Standard Query Operators 766
Anonymous Types with LINQ 796
Summary 806

Chapter 16: LINQ with Query Expressions 809

Introducing Query Expressions 810
Query Expressions Are Just Method Invocations 829
Summary 831

Chapter 17: Building Custom Collections 833

More Collection Interfaces 834
Primary Collection Classes 837
Providing an Indexer 859
Returning null or an Empty Collection 862
Iterators 863
Summary 879

Chapter 18: Reflection, Attributes, and Dynamic Programming 881

Reflection 881
nameof Operator 894
Attributes 895
Programming with Dynamic Objects 920
Summary 931

Chapter 19: Introducing Multithreading 933

Multithreading Basics 935
Asynchronous Tasks 943
Canceling a Task 965
Working with System.Threading 972
Summary 973

Chapter 20: Programming the Task-Based Asynchronous Pattern 975

Synchronously Invoking a High-Latency Operation 975
Asynchronously Invoking a High-Latency Operation Using the TPL 979
The Task-Based Asynchronous Pattern with async and await 984
Introducing Asynchronous Return of ValueTask<T> 991
Asynchronous Streams 994
IAsyncDisposable and the await using Declaration and Statement 998
Using LINQ with IAsyncEnumerable 999
Returning void from an Asynchronous Method 1001
Asynchronous Lambdas and Local Functions 1006
Task Schedulers and the Synchronization Context 1013
async/await with the Windows UI 1015
Summary 1019

Chapter 21: Iterating in Parallel 1021

Executing Loop Iterations in Parallel 1021
Running LINQ Queries in Parallel 1032
Summary 1039

Chapter 22: Thread Synchronization 1041

Why Synchronization? 1042
Timers 1073
Summary 1076

Chapter 23: Platform Interoperability and Unsafe Code 1077

Platform Invoke 1078
Pointers and Addresses 1093
Executing Unsafe Code via a Delegate 1104
Summary 1105

Chapter 24: The Common Language Infrastructure 1107

Defining the Common Language Infrastructure 1107
CLI Implementations 1109
.NET Standard 1113
Base Class Library 1113
C# Compilation to Machine Code 1114
Runtime 1116
Assemblies, Manifests, and Modules 1121
Common Intermediate Language 1124
Common Type System 1125
Common Language Specification 1125
Metadata 1126
.NET Native and Ahead of Time Compilation 1127
Summary 1128

Index 1131

Index of 8.0 Topics 1187

Index of 9.0 Topics 1190

Index of 10.0 Topics 1191

Index of 11.0 Topics 1192

Index of 12.0 Topics 1193

-%
0₫ 0₫
0915920514
0915920514