How To

The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects
By Tan Lee Published on Dec 25, 2024 406

If you're working with Entity Framework Core (EF Core) and encounter the following exception when executing a query with parameters:

How to remove duplicates from a list in C#
By Tan Lee Published on Dec 25, 2024 699

Removing duplicates from a list is a common task in programming. The most efficient way to handle it is by iterating through the list and using a data structure that ensures uniqueness, such as a HashSet.

OverflowException: Value was either too large or too small for an int32
By Tan Lee Published on Dec 25, 2024 720

When working with integer parsing in C#, one of the most common exceptions that developers encounter is the OverflowException: Value was either too large or too small for an Int32.

How to use LinkedList in C#
By Tan Lee Published on Dec 25, 2024 421

In C#, the LinkedList<T> class is a powerful collection designed to handle frequent insertions and removals from both the head and tail of the list efficiently.

How to remove items from a list while iterating in C#
By Tan Lee Published on Dec 25, 2024 822

There are two main approaches for iterating through a List<T> and removing items based on a condition.

How to Search for files in a directory in C#
By Tan Lee Published on Dec 25, 2024 505

In C#, managing and searching files in a directory is a common task, and Directory.EnumerateFiles() provides a powerful and efficient way to find files that meet specific criteria.

How to delete a directory in C#
By Tan Lee Published on Dec 25, 2024 604

In C#, one of the simplest ways to delete a directory is by using the Directory.Delete() method from the System.IO namespace.

How to create directories in C#
By Tan Lee Published on Dec 25, 2024 536

In C#, managing directories is made easy with the Directory.CreateDirectory() method from the System.IO namespace.

How to delete all files in a directory in C#
By Tan Lee Published on Dec 25, 2024 522

In C#, the Directory.EnumerateFiles() method provides an efficient way to retrieve the file paths in a directory, then loop over the file paths and delete each file.

Resolve nullable warnings
By Tan Lee Published on Dec 24, 2024 380

In this article, we will explain the CA1062 warning, how to resolve it, and explore several strategies to handle nullability issues in your methods.

System.BadImageFormatException: Could not load file or assembly
By Tan Lee Published on Dec 24, 2024 663

This occurs when one assembly is compiled for a 32-bit architecture (x86) and another is compiled for a 64-bit architecture (x64), and the two attempt to interact or reference each other.

How to create a custom exception in C#
By Tan Lee Published on Dec 24, 2024 393

Creating a custom exception is straightforward and can help make your application’s error-handling more precise and informative.