Notes on .NET 6 features (#6)

- blazor components
- `field` keyword
- with-expression for anonymous types
- namespace semplification
- lambda signature inference
- static methods and properties on interfaces
- .NET 6 LINQ improvements
- global usings notes
- null parameter checking
- required properties
- native memory allocation
- Minimal APIs
- net 6 implicit imports
This commit is contained in:
Marcello 2021-10-04 22:37:01 +02:00 committed by GitHub
parent 56a963bec8
commit b2abff42c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 787 additions and 323 deletions

View file

@ -47,16 +47,24 @@ The `Where` and `Select` methods are examples of LINQ operators. A LINQ operator
```cs
Enumerable.Range(int start, int end); // IEnumerable<int> of values between start & end
IEnumerable<TSource>.Select(Func<TSource, TResult> selector) // map
IEnumerable<TSource>.Where(Func<T, bool> predicate) // filter
IEnumerable<TSource>.Select(Func<TSource, TResult> selector); // map
IEnumerable<TSource>.Where(Func<T, bool> predicate); // filter
IEnumerable<T>.FirstOrDefault() // first element of IEnumerable or default(T) if empty
IEnumerable<T>.FirstOrDefault(Func<T, bool> predicate) // first element to match predicate or default(T)
IEnumerable<T>.FirstOrDefault(); // first element of IEnumerable or default(T) if empty
IEnumerable<T>.FirstOrDefault(T default); // specify returned default
IEnumerable<T>.FirstOrDefault(Func<T, bool> predicate); // first element to match predicate or default(T)
// same for LastOrDefault & SingleOrDefault
IEnumerable<T>.Chunk(size); // chunk an enumerable into slices of a fixed size
// T must implement IComparable<T>
IEnumerable<T>.Max();
IEnumerable<T>.Max();
IEnumerable<T>.Min();
// allow finding maximal or minimal elements using a key selector
IEnumerable<TSource>.MaxBy(Func<TSource, TResult> selector);
IEnumerable<TSource>.MinBy(Func<TSource, TResult> selector);
IEnumerable<T>.All(Func<T, bool> predicate); // check if condition is true for all elements
IEnumerable<T>.Any(Func<T, bool> predicate); // check if condition is true for at least one element
@ -72,5 +80,5 @@ IEnumerable<TFirst>.Zip(IEnumerable<TSecond> enumerable); // Produces a sequence
```cs
Enumerable.Method(IEnumerable<T> source, args);
// if extension method same as
IEnumerable<T>.Method(args)
IEnumerable<T>.Method(args);
```