How To

C# Add to a Dictionary
By Tan Lee Published on Jan 21, 2025 227

The simplest way to add a key-value pair to a dictionary is by using Dictionary.Add().

How to Modify app.config at Runtime
By Tan Lee Published on Jan 21, 2025 310

When trying to modify the app.config at runtime, it's essential to handle it correctly to avoid errors like:

SqlTypeException: SqlDateTime overflow
By Tan Lee Published on Jan 21, 2025 226

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.'
By Tan Lee Published on Jan 21, 2025 204

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
By Tan Lee Published on Jan 21, 2025 528

The simplest way to filter a dictionary is by using the LINQ Where() and ToDictionary() methods.

C# Remove items from dictionary
By Tan Lee Published on Jan 21, 2025 287

Dictionaries store key/value pairs. To remove one or more items from a dictionary, you can use the following methods:

C# Get value from dictionary
By Tan Lee Published on Jan 21, 2025 312

Dictionaries store key/value pairs. To retrieve the value associated with a specific key, you can use the indexer syntax by providing the key, like this:

ComboBox with Enum Descriptions
By Tan Lee Published on Jan 21, 2025 207

By default, when you load enum values into a ComboBox, it will display the enum names.

How to use relative paths in a Windows Service
By Tan Lee Published on Jan 21, 2025 108

When using relative paths in a Windows Service, it's important to understand that they are resolved relative to the current working directory.

How to check if another form is open
By Tan Lee Published on Jan 21, 2025 352

When developing a Windows Forms application in C#, you might need to check whether a form is already open.

KeyNotFoundException: The given key was not present in the dictionary
By Tan Lee Published on Jan 21, 2025 280

The KeyNotFoundException occurs when you attempt to retrieve a value from a dictionary using a key that doesn’t exist in the dictionary.

How to convert byte array to an object in C#
By Tan Lee Published on Oct 28, 2024 977

To convert a byte array back to an object in C#, you can use deserialization.