This article is a mirror article of machine translation, please click here to jump to the original article.

View: 6631|Reply: 4

[Source] 20 new APIs for .NET 6

[Copy link]
Posted on 2022-9-25 13:10:24 | | |
DateOnly & TimeOnly

.NET 6 introduced two long-awaited types - DateOnly and TimeOnly, which represent the date and time portions of DateTime, respectively.


Parallel.ForEachAsync

It can control the parallelism of multiple asynchronous tasks.


ArgumentNullException.ThrowIfNull()

A small improvement to ArgumentNullException, which doesn't need to check for null in each method before throwing an exception, now only needs to write a line, and response. EnsureSuccessStatusCode(); Similar.


PriorityQueue

The new data structure in .NET 6, PriorityQueue, has an associated priority for each element in the queue, which determines the order in which the element with a small number is prioritized.


RandomAccess

Provides an offset-based API for reading and writing files in a thread-safe manner.


PeriodicTimer

Recognize a completely asynchronous "PeriodicTimer", which is better suited for use in asynchronous scenarios, and it has a method called WaitForNextTickAsync.


Metrics API

.NET 6 implements the OpenTelemetry Metrics API specification, which has a built-in metrics API to create the following metrics through the Meter class

• Counter
• Histogram
• ObservableCounter
• ObservableGauge

Here's how to use it:


Check if the element can be an empty reflection API

It provides emptiness information and context from reflection members:

• ParameterInfo parameter
• FieldInfo field
• PropertyInfo property
• EventInfo events


ProcessId & ProcessPath

Get the process ID and path directly through the Environment.


Configuration Adds GetRequiredSection()

It's the same as DI's GetRequiredService(), if it's missing, it throws an exception.


CSPNG Password Secure Pseudo-Random Number Generator

You can easily generate random value sequences from the Password Secure Pseudorandom Number Generator (CSPNG).

It is useful in the following scenarios:

• Key generation
• Random numbers
• Salt in some signature schemes


Native Memory API

.NET 6 introduces a new API for allocating native memory, and NativeMemory has ways to allocate and free memory.


Power of 2

.NET 6 introduces new methods for handling powers of 2.

• 'IsPow2' determines whether the specified value is a power of 2.
• 'RoundUpToPowerOf2' rounds the specified value to a power of 2.


WaitAsync on Task

You can more easily wait for an asynchronous task to execute, if it times out, it throws a "TimeoutException"


New math API

New methodology:

• SinCos
• ReciprocalEstimate
• ReciprocalSqrtEstimate

New Overload:

• Min, Max, Abs, Sign, Clamp support for nint and nuint
• DivRem returns a tuple, including the quotient and remainder


CollectionsMarshal.GetValueRefOrNullRef

This is used when looping or modifying knot variable structures in the dictionary, which can reduce the copy copying of the structure and avoid the dictionary from repeatedly hashing calculations

The hyperlink login is visible.


ConfigureHostOptions

The new ConfigureHostOptions API on IHostBuilder makes it easier to configure applications.


Async Scope

.NET 6 introduces a new CreateAsyncScope method that throws an exception when you deal with an IAsyncDisposable service, which can be perfectly solved with CreateAsyncScope.


Encryption simplification

• DecryptCbc
• DecryptCfb
• DecryptEcb
• EncryptCbc
• EncryptCfb
• EncryptEcb


(End)





Previous:Performance optimization: SQL Server shuts down the output of the affected number of rows
Next:[WebView2] (1) Initial introduction to Microsoft Edge WebView2 technology
Posted on 2022-9-26 09:56:13 |
Follow Brother Z's pace and prostitute.
Posted on 2022-9-26 16:44:25 |
Follow the pace of the little scum and prostitute.
Posted on 2022-10-8 15:03:10 |
Learn to learn
 Landlord| Posted on 2025-10-20 10:03:51 |
. PriorityQueue priority queue in NET6
https://www.itsvse.com/thread-11098-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com