How To
How to Read a text file line by line in C#
By Tan Lee Published on Mar 05, 2025 361
There are a couple of ways to read a text file line by line:
How to convert a List to a string in C#
By Tan Lee Published on Mar 05, 2025 264
There are two efficient methods for converting a List<T> to a string:
How to use String.Join() in C#
By Tan Lee Published on Mar 05, 2025 313
You can utilize String.Join() to convert a collection of items into a single string with a specified separator (like a comma).
Default access modifiers in C#
By Tan Lee Published on Mar 05, 2025 250
In C#, classes (and other types) have internal access by default, while class members (methods, properties, fields) are private by default.
internal vs protected in C#
By Tan Lee Published on Mar 05, 2025 237
The access modifiers public and private are straightforward: public means everything has access, while private restricts access solely to the class itself.
Synchronous operations are disallowed
By Tan Lee Published on Mar 04, 2025 337
When performing a synchronous I/O operation in ASP.NET Core (such as writing to a file), you may encounter the following exception:
How to convert hex string to byte array in C#
By Tan Lee Published on Mar 04, 2025 412
You can convert a hex string to a byte array in C# using a lookup table and bitwise operations for efficiency.
How to use enum flags in C#
By Tan Lee Published on Mar 04, 2025 309
Enum flags allow you to store multiple values in a single enum variable or parameter. This is a great alternative to passing multiple boolean values. You set multiple values by using a bitwise OR operation.
How to call a static method using reflection in C#
By Tan Lee Published on Mar 04, 2025 442
To call a static method using reflection in C#, follow these steps:
InvalidArgument=Value of ‘0’ is not valid for ‘SelectedIndex’
By Tan Lee Published on Mar 04, 2025 242
You might encounter the following error when setting the SelectedIndex of a ComboBox:
How to Use string interpolation instead of string.Format in C#
By Tan Lee Published on Mar 04, 2025 312
Using string.Format() can lead to errors and runtime exceptions, making code harder to maintain. String interpolation provides a safer, more readable alternative.
How to Fill a Dropdown with Enum Values in C#
By Tan Lee Published on Mar 04, 2025 309
When you need to display enum values in a dropdown (ComboBox control with DropDownStyle=DropDown), it's best to populate the list dynamically instead of manually adding each value.