How To
How to Read a custom config section from app.config in C#
By Tan Lee Published on Mar 20, 2025 337
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 343
When you try to add the AssemblyVersion attribute to your project, for example, to auto-increment the version:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created
By Tan Lee Published on Mar 20, 2025 217
In a WinForms project, if you try to call Invoke or BeginInvoke on a control before the window handle has been created, you'll encounter the following exception:
How to convert string into Secure string in C#
By Tan Lee Published on Jul 06, 2024 1.04K
A SecureString in C# is designed to securely store confidential information such as passwords and PIN codes. It ensures that sensitive data is encrypted and remains protected in memory.
How to retrieve the Executable Path in C#
By Tan Lee Published on Jul 03, 2024 4.13K
In C#, you can retrieve the executable path of the current application using the System.Reflection namespace.
Connection string password with special characters in C#
By Tan Lee Published on Jun 21, 2024 3.11K
When you create a connection string in C# that includes a password with special characters, it's important to properly format and escape those characters to ensure the connection string is interpreted correctly.
Async/Await with a Func delegate in C#
By Tan Lee Published on Jan 21, 2025 616
To make a Func delegate awaitable, you need to return a Task from the delegate.
How to use a list of tuples in C#
By Tan Lee Published on Mar 05, 2025 672
In C#, a list of tuples can be used to store a collection of data where each element contains multiple values.
How to set time to 00:00:00 with GETDATE() in SQL
By Tan Lee Published on Oct 07, 2024 2.39K
In SQL Server, if you want to set the time part of the current date to 00:00:00 while using GETDATE(), you can use the CAST or CONVERT function to strip the time portion.
The name 'Session' does not exist in the current context
By Tan Lee Published on Jun 13, 2024 2.3K
In ASP.NET Core, the Session feature is not enabled by default and must be explicitly configured.
Implementing Two-Factor Authentication with Google Authenticator in ASP.NET Core
By Tan Lee Published on Mar 03, 2025 1.45K
In this article, we'll explore how to implement two-factor authentication (2FA) in an ASP.NET Core web application using Time-Based One-Time Password (TOTP) apps, like Google Authenticator and Authy.
SQL Bulk Insert with SqlBulkCopy in C#
By Tan Lee Published on Mar 19, 2025 260
When dealing with a large number of records, especially in scenarios where inserting a lot of data into the database, a Bulk Insert can drastically improve performance over executing individual INSERT statements. Bulk Insertion can be up to 20x faster than inserting records one by one.