Table of Contents....4
About the Author....14
About the Technical Reviewer....15
Introduction....16
Chapter 1: Hello World....18
Choosing an IDE....18
Creating a Project....19
Hello World....20
IntelliSense....21
Chapter 2: Compile and Run....22
Visual Studio Compilation....22
Console Compilation....22
Comments....23
Chapter 3: Variables....25
Data Types....25
Declaration....26
Assignment....26
Integer Types....27
Floating-Point Types....28
Char Type....29
Bool Type....29
Variable Scope....29
Chapter 4: Operators....30
Arithmetic Operators....30
Assignment Operators....31
Increment and Decrement Operators....31
Comparison Operators....32
Logical Operators....32
Bitwise Operators....33
Operator Precedents....33
Chapter 5: Strings....35
String Concatenation....35
Escape Characters....36
String Compare....37
String Members....37
StringBuilder Class....38
Chapter 6: Arrays....39
Array Declaration....39
Array Allocation....39
Array Assignment....40
Array Access....40
Rectangular Arrays....40
Jagged Arrays....41
Chapter 7: Conditionals....42
If Statement....42
Switch Statement....43
Goto Statement....44
Switch Expression....45
Ternary Operator....45
Chapter 8: Loops....46
While Loop....46
Do-While Loop....46
For Loop....47
Foreach Loop....48
Break and Continue....48
Chapter 9: Methods....49
Defining Methods....49
Calling Methods....50
Method Parameters....50
Params Keyword....51
Method Overloading....51
Optional Parameters....52
Named Arguments....53
Return Statement....53
Value and Reference Types....54
Pass by Value....55
Pass by Reference....55
Ref Keyword....56
Out Keyword....57
Local Methods....58
Chapter 10: Class....60
Object Creation....60
Accessing Object Members....61
Constructor....62
This Keyword....63
Constructor Overloading....63
Constructor Chaining....64
Initial Field Values....64
Default Constructor....65
Object Initializers....65
Partial Class....66
Garbage Collector....67
Finalizer....67
Null and Nullable Types....68
Nullable Value Types....70
Null-Coalescing Operator....70
Null-Conditional Operator....71
Null-Forgiving Operator....72
Default Values....72
Type Inference....73
Anonymous Types....73
Chapter 11: Inheritance....75
Object Class....75
Downcast and Upcast....76
Boxing....77
Unboxing....77
The is and as Keywords....77
Pattern Matching....78
Chapter 12: Redefining Members....81
Hiding Members....81
Overriding Members....82
Hiding and Overriding....82
Sealed Keyword....83
Base Keyword....83
Chapter 13: Access Levels....86
Private Access....86
Protected Access....87
Internal Access....88
Protected Internal Access....89
Private Protected Access....89
Public Access....90
Top-Level Access Levels....91
Inner Classes....91
Access Level Guideline....92
Chapter 14: Static....93
Accessing Static Members....94
Static Methods....94
Static Fields....95
Static Classes....95
Static Constructor....96
Static Local Functions....96
Extension Methods....97
Chapter 15: Properties....99
Property Advantages....100
Read-Only and Write-Only Properties....102
Property Access Levels....102
Auto-implemented Properties....103
Chapter 16: Indexers....105
Indexer Parameters....106
Indexer Overloading....107
Ranges and Indices....108
Chapter 17: Interfaces....109
Interface Signatures....109
Interface Example....110
Functionality Interface....111
Class Interface....111
Default Implementations....112
Chapter 18: Abstract....114
Abstract Members....114
Abstract Example....115
Abstract Classes and Interfaces....116
Chapter 19: Namespaces....118
Nested Namespaces....118
Namespace Access....119
File-Scoped Namespaces....120
Using Directive....120
Top-Level Statements....122
Chapter 20: Enum....124
Enum Example....124
Enum Constant Values....125
Enum Constant Type....125
Enum Access Levels and Scope....126
Enum Methods....126
Chapter 21: Exception Handling....127
Try-Catch Statement....127
Catch Block....128
Exception Filters....129
Finally Block....130
The using Statement....132
Throwing Exceptions....132
Chapter 22: Operator Overloading....135
Operator Overloading Example....135
Binary Operator Overloading....136
Unary Operator Overloading....136
Return Types and Parameters....137
Overloadable Operators....137
True and False Operator Overloading....138
Chapter 23: Custom Conversions....140
Implicit Conversion Methods....140
Explicit Conversion Methods....141
Chapter 24: Struct....142
Struct Variable....142
Struct Constructors....143
Struct Field Initializers....144
Struct Inheritance....144
Struct Guideline....145
Chapter 25: Record....146
Record Behavior....147
Record Structs....149
Record Guidelines....150
Chapter 26: Preprocessors....151
Preprocessor Syntax....152
Conditional Compilation Symbols....152
Conditional Compilation....152
Diagnostic Directives....153
Line Directive....154
Region Directives....154
Chapter 27: Delegates....155
Anonymous Methods....156
Lambda Expressions....156
Expression Body Members....158
Type Inference....159
Capturing Outer Variables....160
Multicast Delegates....161
Delegate Signature....162
Delegates As Parameters....163
Chapter 28: Events....165
Publisher....165
Event Keyword....166
Event Caller....166
Raising Events....167
Subscriber....168
Subscribing to Events....169
Chapter 29: Generics....170
Generic Methods....170
Calling Generic Methods....171
Generic Type Parameters....172
Default Value....172
Generic Classes....173
Generic Class Inheritance....174
Generic Interfaces....175
Generic Delegates....176
Generic Events....176
Generics and Object....177
Constraints....177
Multiple Constraints....178
Why Use Constraints....179
Chapter 30: Constants....181
Local Constants....181
Constant Fields....182
Readonly....182
In Parameters....184
Constant Guidelines....185
Chapter 31: Asynchronous Methods....186
The Async and Await Keywords....186
Async Return Types....187
Custom Async Methods....188
Extended Return Types....189
Async Streams....190
Index....192
Discover what’s new in C# and .NET for Windows programming. This book is a condensed code and syntax reference to the C# programming language, updated with the latest features of version 10 for .NET 6.You’ll review the essential C# 10 and earlier syntax, not previously covered, in a well-organized format that can be used as a handy reference. Specifically, unions, generic attributes, CallerArgumentExpression, params span, Records, Init only setters, Top-level statements, Pattern matching enhancements, Native sized integers, Function pointers and more.You’ll find a concise reference to the C# language syntax: short, simple, and focused code examples; a well laid out table of contents; and a comprehensive index allowing easy review. You won’t find any technical jargon, bloated samples, drawn-out history lessons, or witty stories. What you will find is a language reference that is to the point and highly accessible.The book is a must-have for any C# programmer.
Those with some experience in programming, looking for a quick, handy reference. Some C# or .NET recommended but not necessary.