How To

How to Convert Unix Timestamp to DateTime in C#
3/21/2025 2:44:36 AM  1.78K

In .NET, you can easily convert Unix timestamps to DateTime objects by using DateTimeOffset.FromUnixTimeSeconds method.

How to use Channel as an async queue in C#
3/21/2025 2:32:48 AM  39

The Channel class from System.Threading.Channels provides a non-blocking, asynchronous queue that implements the producer-consumer pattern.

Case sensitivity in JSON deserialization
3/21/2025 2:24:24 AM  51

By default, Newtonsoft.Json uses case-insensitive deserialization, while System.Text.Json performs case-sensitive deserialization.

The JSON value could not be converted to Enum
3/21/2025 2:13:48 AM  75

When using System.Text.Json to deserialize JSON that includes a string representation of an enum, you may encounter the following error:

Case insensitive dictionary in C#
3/21/2025 2:09:50 AM  212

Dictionaries in C# are case sensitive by default when using string keys.

Deserialize JSON to Dynamic Object Using Newtonsoft.Json in C#
3/21/2025 2:09:29 AM  465

When you need to deserialize JSON without creating multiple classes, you can either deserialize it to a dictionary or to a dynamic object using Newtonsoft.Json.

How to Pass in a Func to override behavior in C#
3/21/2025 2:08:27 AM  112

In C#, if I want to change the behavior of a method from the outside, I can pass in a function pointer. This technique exists in most programming languages and can be used to implement patterns like the Strategy Pattern.

How to Get a file’s checksum using any hashing algorithm in C#
3/20/2025 2:51:27 AM  53

This article demonstrates how to calculate a file’s checksum using several hashing algorithms, including MD5, SHA1, SHA256, SHA384, and SHA512.

How to Get a file’s MD5 checksum
3/20/2025 2:46:23 AM  48

To retrieve a file’s SHA256 checksum, you can use the Get-FileHash cmdlet. This feature has been available since PowerShell v4.

Handle a faulted Task’s exception in C#
3/20/2025 2:41:59 AM  29

When a Task throws an exception and ceases execution, it becomes "faulted." The key question is: how do you access the exception thrown by a faulted Task?

Serializer options cannot be changed once serialization or deserialization has occurred
3/20/2025 2:36:59 AM  42

When using System.Text.Json, it’s highly recommended to reuse JsonSerializerOptions objects, as this provides a significant speed boost (up to 200 times faster) for subsequent serialization and deserialization operations.

How to use format strings with string interpolation in C#
3/20/2025 2:33:17 AM  23

In C#, interpolated strings follow this structure: {variable:format}, where the format part is optional. Normally, the interpolated string would look like this: $"My name is {name}".