C# 10 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library, 4th Ed

C# 10 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library, 4th Ed

C# 10 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library, 4th Ed

Автор: Mikael Olsson
Дата выхода: 2022
Издательство: Apress Media, LLC.
Количество страниц: 197
Размер файла: 1,7 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

About the Author ................................................................................................xiii
About the Technical Reviewer ...............................................................................xv
Introduction .......................................................................................................xvii
Chapter 4: Operators ..........................................................................................15
Arithmetic Operators ...........................................................................................15
Assignment Operators ........................................................................................16
Increment and Decrement Operators ....................................................................16
Comparison Operators ........................................................................................17
Logical Operators ................................................................................................17
Bitwise Operators ...............................................................................................18
Operator Precedents ...........................................................................................18
Chapter 5: Strings ..............................................................................................21
String Concatenation ..........................................................................................21
Escape Characters ..............................................................................................22
String Compare ...................................................................................................23
String Members ..................................................................................................23
StringBuilder Class .............................................................................................24
Chapter 6: Arrays ...............................................................................................25
Array Declaration ................................................................................................25
Array Allocation ...................................................................................................25
Array Assignment ................................................................................................26
Array Access .......................................................................................................26
Rectangular Arrays ..............................................................................................26
Jagged Arrays .....................................................................................................27
Chapter 7: Conditionals ........................................................................................29
If Statement ........................................................................................................29
Switch Statement ...............................................................................................30
Goto Statement ...................................................................................................31
Switch Expression ...............................................................................................32
Ternary Operator .................................................................................................32
Chapter 8: Loops .................................................................................................33
While Loop ..........................................................................................................33
Do-While Loop .....................................................................................................33
For Loop ..............................................................................................................34
Foreach Loop ......................................................................................................35
Break and Continue .............................................................................................35
Chapter 9: Methods .............................................................................................37
Defining Methods ................................................................................................37
Calling Methods ..................................................................................................38
Method Parameters ............................................................................................38
Params Keyword .................................................................................................39
Method Overloading ............................................................................................39
Optional Parameters ...........................................................................................40
Named Arguments ..............................................................................................41
Return Statement ................................................................................................41
Value and Reference Types .................................................................................42
Pass by Value ......................................................................................................43
Pass by Reference ..............................................................................................43
Ref Keyword ........................................................................................................44
Out Keyword ........................................................................................................45
Local Methods .....................................................................................................46
Chapter 10: Class................................................................................................49
Object Creation ...................................................................................................49
Accessing Object Members ...................................................................................50
Constructor .........................................................................................................51
This Keyword ......................................................................................................52
Constructor Overloading .....................................................................................52
Constructor Chaining ..........................................................................................53
Initial Field Values ...............................................................................................53
Default Constructor .............................................................................................54
Object Initializers ................................................................................................54
Partial Class ........................................................................................................55
Garbage Collector ...............................................................................................56
Finalizer ..............................................................................................................56
Null and Nullable Types .......................................................................................57
Nullable Value Types ...........................................................................................59
Null-Coalescing Operator ....................................................................................59
Null-Conditional Operator ...................................................................................60
Null-Forgiving Operator .......................................................................................61
Default Values .....................................................................................................61
Type Inference .....................................................................................................62
Anonymous Types ...............................................................................................62
Chapter 11: Inheritance .......................................................................................65
Object Class ........................................................................................................65
Downcast and Upcast .........................................................................................66
Boxing .................................................................................................................67
Unboxing .............................................................................................................67
The is and as Keywords ......................................................................................67
Pattern Matching ................................................................................................68
Chapter 12: Redefining Members ..........................................................................71
Hiding Members ..................................................................................................71
Overriding Members ...........................................................................................72
Hiding and Overriding .........................................................................................72
Sealed Keyword ..................................................................................................73
Base Keyword .....................................................................................................73
Chapter 13: Access Levels ....................................................................................77
Private Access .....................................................................................................77
Protected Access ................................................................................................78
Internal Access....................................................................................................79
Protected Internal Access ...................................................................................80
Private Protected Access ....................................................................................80
Public Access ......................................................................................................81
Top-Level Access Levels .....................................................................................82
Inner Classes ......................................................................................................82
Access Level Guideline .......................................................................................83
Chapter 14: Static ..............................................................................................85
Accessing Static Members ....................................................................................86
Static Methods ....................................................................................................86
Static Fields ........................................................................................................87
Static Classes .....................................................................................................87
Static Constructor ...............................................................................................88
Static Local Functions .........................................................................................88
Extension Methods ..............................................................................................89
Chapter 15: Properties..........................................................................................91
Property Advantages ...........................................................................................92
Read-Only and Write-Only Properties ...................................................................94
Property Access Levels .......................................................................................94
Auto-implemented Properties ...............................................................................95
Chapter 16: Indexers ..........................................................................................97
Indexer Parameters .............................................................................................98
Indexer Overloading ............................................................................................99
Ranges and Indices ...........................................................................................100
Chapter 17: Interfaces .......................................................................................101
Interface Signatures ..........................................................................................101
Interface Example .............................................................................................102
Functionality Interface ......................................................................................103
Class Interface ..................................................................................................103
Default Implementations ...................................................................................104
Chapter 18: Abstract...........................................................................................107
Abstract Members .............................................................................................107
Abstract Example ..............................................................................................108
Abstract Classes and Interfaces ..........................................................................109
Chapter 19: Namespaces ...................................................................................111
Nested Namespaces .........................................................................................111
Namespace Access ...........................................................................................112
File-Scoped Namespaces ...................................................................................113
Using Directive ..................................................................................................113
Top-Level Statements .......................................................................................115
Chapter 20: Enum .............................................................................................117
Enum Example ..................................................................................................117
Enum Constant Values ......................................................................................118
Enum Constant Type ..........................................................................................118
Enum Access Levels and Scope ...........................................................................119
Enum Methods ..................................................................................................119
Chapter 21: Exception Handling ..........................................................................121
Try-Catch Statement .........................................................................................121
Catch Block .......................................................................................................122
Exception Filters ...............................................................................................123
Finally Block ......................................................................................................124
The using Statement .........................................................................................126
Throwing Exceptions .........................................................................................126
Chapter 22: Operator Overloading .....................................................................129
Operator Overloading Example .........................................................................129
Binary Operator Overloading .............................................................................130
Unary Operator Overloading ..............................................................................130
Return Types and Parameters ...........................................................................131
Overloadable Operators ....................................................................................131
True and False Operator Overloading ................................................................132
Chapter 23: Custom Conversions .....................................................................135
Implicit Conversion Methods .............................................................................135
Explicit Conversion Methods .............................................................................136
Chapter 24: Struct ............................................................................................137
Struct Variable ...................................................................................................137
Struct Constructors ...........................................................................................138
Struct Field Initializers ......................................................................................139
Struct Inheritance .............................................................................................139
Struct Guideline ................................................................................................140
Chapter 25: Record ...........................................................................................141
Record Behavior ................................................................................................142
Record Structs ..................................................................................................144
Record Guidelines .............................................................................................145
Chapter 26: Preprocessors .................................................................................147
Preprocessor Syntax .........................................................................................148
Conditional Compilation Symbols .....................................................................148
Conditional Compilation ...............................................................................148
Diagnostic Directives ...................................................................................149
Line Directive ...............................................................................................150
Region Directives .........................................................................................150
Chapter 27: Delegates ....................................................................................151
Anonymous Methods ........................................................................................152
Lambda Expressions .........................................................................................152
Expression Body Members ..............................................................................154
Type Inference .............................................................................................155
Capturing Outer Variables ................................................................................156
Multicast Delegates ..........................................................................................157
Delegate Signature ...........................................................................................158
Delegates As Parameters ..................................................................................159
Chapter 28: Events ............................................................................................161
Publisher ...........................................................................................................161
Event Keyword ..................................................................................................162
Event Caller .......................................................................................................162
Raising Events ..................................................................................................163
Subscriber .........................................................................................................164
Subscribing to Events .......................................................................................165
Chapter 29: Generics ........................................................................................167
Generic Methods ...............................................................................................167
Calling Generic Methods ...................................................................................168
Generic Type Parameters ..................................................................................169
Default Value .....................................................................................................169
Generic Classes ................................................................................................170
Generic Class Inheritance .................................................................................171
Generic Interfaces .............................................................................................172
Generic Delegates .............................................................................................173
Generic Events ..................................................................................................173
Generics and Object ..........................................................................................174
Constraints ........................................................................................................174
Multiple Constraints ..........................................................................................175
Why Use Constraints .........................................................................................176
Chapter 30: Constants .......................................................................................179
Local Constants .................................................................................................179
Constant Fields .................................................................................................180
Readonly ...........................................................................................................180
In Parameters ....................................................................................................182
Constant Guidelines ..........................................................................................183
Chapter 31: Asynchronous Methods ....................................................................185
The Async and Await Keywords ..........................................................................185
Async Return Types ...........................................................................................186
Custom Async Methods .....................................................................................187
Extended Return Types .....................................................................................188
Async Streams ..................................................................................................189
Index ..............................................................................................................191

 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.

What You Will Learn
 

  • Employ nullable reference types
  • Work with ranges and indices
  • Apply recursive patterns to your applications
  • Use switch expressions

Who This Book Is For

 Those with some experience in programming, looking for a quick, handy reference. Some C# or .NET recommended but not necessary.
 


Похожее:

Список отзывов:

Нет отзывов к книге.