How To
How to read problem details JSON using HttpClient in C#
1/21/2025 9:05:55 AM 217
Problem details (RFC7807) is a standardized format for error responses, which uses the `Content-Type` of `application/problem+json`, an appropriate HTTP status code (e.g., 400 – Bad Request), and a response body structured as follows:
How to Cancel an HttpClient Request in C#
1/21/2025 8:47:28 AM 120
In C#, you can achieve this by using the CancellationToken with the HttpClient class.
How to get the status code using HttpClient in C#
1/21/2025 8:41:32 AM 241
When working with HttpClient in C#, it's important to handle the response status codes to ensure that your application behaves as expected.
C# Async Main
1/21/2025 8:22:57 AM 72
The Async Main feature, introduced in C# 7.1, allows you to make the Main() method asynchronous.
The referenced component could not be found
1/21/2025 8:06:11 AM 136
When opening a C# project in Visual Studio, you may encounter a frustrating error where none of the references load correctly.
Fixing the Sync over Async Antipattern in C#
1/21/2025 7:51:41 AM 77
One common mistake developers make is the Sync over Async antipattern, which occurs when blocking waits are used in asynchronous methods instead of awaiting them properly.
C# Add to a Dictionary
1/21/2025 7:45:11 AM 121
The simplest way to add a key-value pair to a dictionary is by using Dictionary.Add().
How to Modify app.config at Runtime
1/21/2025 7:43:22 AM 151
When trying to modify the app.config at runtime, it's essential to handle it correctly to avoid errors like:
SqlTypeException: SqlDateTime overflow
1/21/2025 7:35:18 AM 124
The System.Data.SqlTypes.SqlTypeException: ‘SqlDateTime overflow.' error occurs when you try to insert a DateTime value that is outside the valid range for SQL Server's datetime data type.
SqlTypeException: 'Overflow error converting to data type int.'
1/21/2025 7:30:50 AM 111
The System.Data.SqlTypes.SqlTypeException: 'Overflow error converting to data type int.' occurs when you try to insert a value that is outside the valid range of the SQL int data type, which is between -2,147,483,648 and 2,147,483,647.
C# Filter a dictionary
1/21/2025 7:16:22 AM 136
The simplest way to filter a dictionary is by using the LINQ Where() and ToDictionary() methods.
C# Remove items from dictionary
1/21/2025 7:04:26 AM 113
Dictionaries store key/value pairs. To remove one or more items from a dictionary, you can use the following methods: