C# – How to deconstruct an object

Deconstructing an object means assigning its properties to several variables with a one-liner using deconstruction assignment syntax (also referred to as destructuring or unpacking). Here’s an example of deconstructing an object: This outputs the following: Several built-in types already support deconstruction – such as tuples, dictionary (KeyValuePair), and records. You can enable deconstruction for any … Read more

C# – How to add request headers when using HttpClient

There are two ways add request headers when using HttpClient: In this article, I’ll show examples of both ways to add request headers. Add an unchanging header for all requests Let’s say you’re adding an API Key header. It needs to be included in all requests and the value won’t change. To add this request … Read more