How To
How to Convert Int to Byte Array in C#
By Tan Lee Published on Jan 20, 2025 499
When working with integers in C#, you might encounter situations where you need to convert an integer to a byte array.
How to Convert string list to int list in C#
By Tan Lee Published on Feb 05, 2025 533
To convert a list of strings to a list of integers in C#, you can use several approaches.
How to Pass string parameter in an onclick function
By Tan Lee Published on Feb 16, 2024 1.65K
To pass a parameter using the onclick event in HTML, you can define a JavaScript function that accepts parameters and call it from the onclick attribute.
How to convert timestamp to date in C#
By Tan Lee Published on Nov 16, 2024 709
In C#, to convert a timestamp to a DateTime object, you can use the DateTimeOffset or DateTime class.
How to Get all files in a folder in C#
By Tan Lee Published on Dec 24, 2024 951
If you need to get all files in a folder, there are two primary ways to do it: using Directory.GetFiles() and Directory.EnumerateFiles().
How to Convert Unix Timestamp to DateTime in C#
By Tan Lee Published on Jul 11, 2024 2.05K
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#
By Tan Lee Published on Mar 21, 2025 175
The Channel class from System.Threading.Channels provides a non-blocking, asynchronous queue that implements the producer-consumer pattern.
Case sensitivity in JSON deserialization
By Tan Lee Published on Mar 21, 2025 219
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
By Tan Lee Published on Mar 21, 2025 226
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#
By Tan Lee Published on Jan 21, 2025 298
Dictionaries in C# are case sensitive by default when using string keys.
Deserialize JSON to Dynamic Object Using Newtonsoft.Json in C#
By Tan Lee Published on Jan 21, 2025 608
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#
By Tan Lee Published on Jan 21, 2025 158
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.