How To
How to Get a file’s checksum using any hashing algorithm in C#
By Tan Lee Published on Mar 20, 2025 150
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
By Tan Lee Published on Mar 20, 2025 119
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#
By Tan Lee Published on Mar 20, 2025 165
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
By Tan Lee Published on Mar 20, 2025 99
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#
By Tan Lee Published on Mar 20, 2025 113
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}".
How to Query JSON in SQL Server
By Tan Lee Published on Mar 20, 2025 124
Since SQL Server 2016, Microsoft has provided built-in support for managing and querying JSON data. This enables users to store, retrieve, and manipulate JSON documents directly within SQL Server.
How to modify JSON in SQL Server
By Tan Lee Published on Mar 20, 2025 150
In SQL Server, there are a couple of ways to modify JSON data within a table:
How to Check if an IP range is valid in C#
By Tan Lee Published on Mar 20, 2025 112
If you have an IP range defined by a starting and ending IP address (e.g., from user input or a configuration file), you can validate it using the following steps:
Merge two dictionaries in-place in C#
By Tan Lee Published on Mar 20, 2025 113
When merging two dictionaries, you have the option to either perform the merge in-place or create a new dictionary and copy the values over.
Generating XML Documentation and Including It in a NuGet Package in C#
By Tan Lee Published on Mar 20, 2025 164
XML documentation comments in C# serve two main purposes:
How to Read a custom config section from app.config in C#
By Tan Lee Published on Mar 20, 2025 130
In this article, I’ll show you how to retrieve a custom configuration section from app.config and load it into your own configuration class.
Duplicate 'AssemblyVersion' attribute in C#
By Tan Lee Published on Mar 20, 2025 121
When you try to add the AssemblyVersion attribute to your project, for example, to auto-increment the version: