Search

How to update UI from another thread in C#
By Tan Lee Published on Dec 21, 2024 2.37K

In C#, you cannot directly update the UI from a background thread because Windows Forms and WPF (UI frameworks) require UI updates to happen on the main UI thread.

Read more
Serialize and Deserialize a Multidimensional Array in JSON using C#
By Tan Lee Published on Dec 25, 2024 1.08K

By default, System.Text.Json does not support serializing or deserializing multidimensional arrays.

Read more
How to Search DataGridView by using TextBox in C#
By Tan Lee Published on Aug 13, 2017 27.46K

To filter or search a DataGridView using a TextBox in C#, you typically bind the DataGridView to a DataTable or similar data source and use a DataView to filter the rows.

Read more
How to retrieve the Downloads Directory Path in C#
By Tan Lee Published on Jun 27, 2024 3.24K

In C#, you can retrieve the path to the user's Downloads directory using the Environment class and the SpecialFolder enumeration.

Read more
Retrieve a Single Row with Dapper in C#
By Tan Lee Published on Jan 18, 2025 610

When you need to retrieve a single row from a database using Dapper, the simplest approach is to use the QuerySingleOrDefault() method.

Read more
How to Print RDLC Report without Report Viewer in C#
By Tan Lee Published on Jul 17, 2024 33.02K

To print an RDLC report without using the Report Viewer control in a C# Windows Forms application, you can follow these steps.

Read more
How to Convert string to JSON in C#
By Tan Lee Published on Nov 19, 2024 2.41K

You can convert a string to a JSON object in C# using the `JsonSerializer.Deserialize` method from the `System.Text.Json` namespace.

Read more
How to use decimal precision and scale in EF Code First
By Tan Lee Published on Jul 11, 2024 1.08K

In C# Entity Framework, when you want to use the Decimal data type for your entity properties, you can follow these steps.

Read more
Ignoring Namespaces in XML when Deserializing in C#
By Tan Lee Published on Jan 10, 2025 1.34K

Namespaces in XML can be tricky to handle, especially when you're working with documents that sometimes include them and sometimes do not.

Read more
How to convert GUID to Integer in C#
By Tan Lee Published on Nov 10, 2024 736

Converting a GUID to an integer in C# isn't a straightforward process because a GUID is a 128-bit value, while an integer in C# is only 32-bits.

Read more
How to Print DataGridView with Header and Footer in C#
By Tan Lee Published on Jul 13, 2024 8.76K

Printing a DataGridView with header and footer in C# involves several steps, including setting up the printing functionality, handling page breaks, and customizing headers and footers.

Read more
How to consume an SSE endpoint using HttpClient in C#
By Tan Lee Published on Jan 22, 2025 482

Server-Sent Events (SSE) offer an efficient way for clients to receive real-time updates from a server.

Read more
Group By in C# LINQ
By Tan Lee Published on Jan 20, 2025 162

In C#, LINQ's Group By is a query operator that allows you to organize elements of a sequence into groups based on a specified key selector function.

Read more
How to Use the New Lock Object in C#
By Tan Lee Published on Jan 15, 2025 386

C# has supported thread synchronization with the `lock` keyword since its early versions, ensuring that only one thread executes a block of code at a time.

Read more
Solr Search in .NET Core
By Tan Lee Published on Jan 10, 2025 566

.NET Core offers robust support for interacting with the Solr search engine.

Read more
Handling 415 Unsupported Media Type in .NET Core API
By Tan Lee Published on Jan 10, 2025 1.12K

In .NET Core APIs, the default content type for incoming requests is application/json.

Read more
Implementing HTTP Timeout Retries with Polly and IHttpClientBuilder
By Tan Lee Published on Jan 09, 2025 544

Polly's retry functionality combined with IHttpClientBuilder provides an elegant solution to configure retry logic at the application startup.

Read more
How to implement a distributed cache in ASP.NET Core
By Tan Lee Published on Jan 07, 2025 290

ASP.Net Core offers support for various caching techniques, including in-memory caching, response caching, and built-in distributed caching.

Read more
How to use Tuple in C#
By Tan Lee Published on Jan 07, 2025 200

Tuples are data structures that store a fixed-size, ordered sequence of immutable, heterogeneous elements, meaning each element can be of a different type.

Read more
How to use Lamar in ASP.NET Core
By Tan Lee Published on Jan 07, 2025 202

ASP.Net Core has built-in support for dependency injection (DI) with a minimal DI container.

Read more
How to use Singleton pattern in C#
By Tan Lee Published on Feb 16, 2024 748

The Singleton is a creational design pattern that ensures a class has only one instance.

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

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.

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

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

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

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.

Read more
Objects added to a BindingSource’s list must all be of the same type
By Tan Lee Published on Dec 21, 2024 407

When working with data binding in C#, one common scenario is binding a list of objects to a user interface control (like a DataGridView, ComboBox, or ListBox).

Read more
How to use CORS in ASP.NET Core
By Tan Lee Published on Dec 19, 2024 500

In this article, we will explore one of the challenges users faced in the early days of web development the Same-Origin Policy (SOP) and how Cross-Origin Resource Sharing (CORS) became a solution.

Read more
How to Run Background Tasks in ASP.NET Core with Hosted Services
By Tan Lee Published on Dec 19, 2024 413

One of the features I appreciate most about .NET Core is how easily it allows you to implement and run background tasks in an ASP.NET Core project.

Read more
10 Common Mistakes ASP.NET Developers Should Avoid
By Tan Lee Published on Dec 16, 2024 431

ASP.NET Core is a powerful framework for building modern web applications, but even seasoned developers can make mistakes that impact performance, security, or maintainability.

Read more
How to Insert Update Delete Search data from local database in C#
By Tan Lee Published on Jul 24, 2017 10.55K

Creating a Telephone Diary (Phone Book) application in C# using Material Skin with a local database can be broken down into the following steps.

Read more
How to Generate Serial Key in C#
By Tan Lee Published on Jul 03, 2017 10.5K

Serial key generation and validation are crucial components of software licensing.

Read more