When you need answers about using C# 8.0, this tightly focused and practical book tells you exactly what you need to know without long intros or bloated samples. Easy to browse, C# 8.0 Pocket Reference is ideal as a quick source of information or as a guide to get you rapidly up to speed if you already know Java, C++, or an earlier C# version.
All programs and code snippets are available as interactive samples in LINQPad. You can edit these samples and instantly see the results without needing to set up projects in Visual Studio. Written by the author of C# 7.0 in a Nutshell, this pocket reference covers C# 8.0 without skimping on detail, including:
- C# fundamentals and features new to C# 8.0
- Advanced topics like operator overloading, type constraints, iterators, nullable types, operator lifting, lambda expressions, and closures
- LINQ: sequences, lazy execution, standard query operators, and query expressions
- Unsafe code and pointers, custom attributes, preprocessor directives, and XML documentation
Author(s): Joseph Albahari, Ben Albahari
Edition: 1
Publisher: O'Reilly Media
Year: 2019
Language: English
Pages: 248
Tags: C#; C# 8.0; Language Reference;
Cover
Copyright
Table of Contents
C# 8.0 Pocket Reference
A First C# Program
Compilation
Syntax
Identifiers and Keywords
Literals, Punctuators, and Operators
Comments
Type Basics
Predefined Type Examples
Custom Type Examples
Conversions
Value Types versus Reference Types
Predefined Type Taxonomy
Numeric Types
Numeric Literals
Numeric Conversions
Arithmetic Operators
Increment and Decrement Operators
Specialized Integral Operations
8- and 16-Bit Integral Types
Special Float and Double Values
double versus decimal
Real Number Rounding Errors
Boolean Type and Operators
Equality and Comparison Operators
Conditional Operators
Strings and Characters
String Type
Arrays
Default Element Initialization
Indices and Ranges (C# 8)
Multidimensional Arrays
Simplified Array Initialization Expressions
Variables and Parameters
The Stack and the Heap
Definite Assignment
Default Values
Parameters
var—Implicitly Typed Local Variables
Expressions and Operators
Assignment Expressions
Operator Precedence and Associativity
Operator Table
Null Operators
Null-Coalescing Operator
Null-Conditional Operator
Null-Coalescing Assignment (C# 8)
Statements
Declaration Statements
Expression Statements
Selection Statements
Iteration Statements
Jump Statements
Namespaces
The using Directive
using static
Rules Within a Namespace
Aliasing Types and Namespaces
Classes
Fields
Constants
Methods
Instance Constructors
Deconstructors
Object Initializers
The this Reference
Properties
Indexers
Static Constructors
Static Classes
Finalizers
Partial Types and Methods
The nameof Operator
Inheritance
Polymorphism
Casting and Reference Conversions
Virtual Function Members
Abstract Classes and Abstract Members
Hiding Inherited Members
Sealing Functions and Classes
The base Keyword
Constructors and Inheritance
Overloading and Resolution
The object Type
Boxing and Unboxing
Static and Runtime Type Checking
The GetType Method and typeof Operator
Object Member Listing
Equals, ReferenceEquals, and GetHashCode
The ToString Method
Structs
Struct Construction Semantics
readonly Structs and Functions
Access Modifiers
Friend Assemblies
Accessibility Capping
Interfaces
Extending an Interface
Explicit Interface Implementation
Implementing Interface Members Virtually
Reimplementing an Interface in a Subclass
Default Interface Members (C# 8)
Enums
Enum Conversions
Flags Enums
Enum Operators
Nested Types
Generics
Generic Types
Generic Methods
Declaring Type Parameters
typeof and Unbound Generic Types
The default Generic Value
Generic Constraints
Subclassing Generic Types
Self-Referencing Generic Declarations
Static Data
Covariance
Contravariance
Delegates
Writing Plug-In Methods with Delegates
Multicast Delegates
Instance versus Static Method Targets
Generic Delegate Types
The Func and Action Delegates
Delegate Compatibility
Events
Standard Event Pattern
Event Accessors
Lambda Expressions
Capturing Outer Variables
Lambda Expressions versus Local Methods
Anonymous Methods
try Statements and Exceptions
The catch Clause
The finally Block
Throwing Exceptions
Key Properties of System.Exception
Common Exception Types
Enumeration and Iterators
Enumeration
Collection Initializers
Iterators
Iterator Semantics
Composing Sequences
Nullable (Value) Types
Nullable Struct
Nullable Conversions
Boxing/Unboxing Nullable Values
Operator Lifting
bool? with & and | Operators
Nullable Types and Null Operators
Nullable Reference Types (C# 8)
Extension Methods
Extension Method Chaining
Ambiguity and Resolution
Anonymous Types
Tuples
Naming Tuple Elements
Deconstructing Tuples
LINQ
LINQ Fundamentals
Deferred Execution
Standard Query Operators
Chaining Query Operators
Query Expressions
The let Keyword
Query Continuations
Multiple Generators
Joining
Ordering
Grouping
OfType and Cast
Dynamic Binding
Static Binding versus Dynamic Binding
Custom Binding
Language Binding
RuntimeBinderException
Runtime Representation of dynamic
Dynamic Conversions
var versus dynamic
Dynamic Expressions
Dynamic Member Overload Resolution
Uncallable Functions
Operator Overloading
Operator Functions
Overloading Equality and Comparison Operators
Custom Implicit and Explicit Conversions
Attributes
Attribute Classes
Named and Positional Attribute Parameters
Attribute Targets
Specifying Multiple Attributes
Writing Custom Attributes
Retrieving Attributes at Runtime
Caller Info Attributes
Asynchronous Functions
The await and async Keywords
Capturing Local State
Writing Asynchronous Functions
Parallelism
Asynchronous Lambda Expressions
Asynchronous Streams (C# 8)
Unsafe Code and Pointers
Pointer Basics
Unsafe Code
The fixed Statement
The Pointer-to-Member Operator
The stackalloc Keyword
Fixed-size buffers
void*
Preprocessor Directives
Pragma Warning
XML Documentation
Standard XML Documentation Tags
Index