Search

Duplicate 'AssemblyVersion' attribute in C#
By Tan Lee Published on Mar 20, 2025 131

When you try to add the AssemblyVersion attribute to your project, for example, to auto-increment the version:

Read more
How to convert string into Secure string in C#
By Tan Lee Published on Jul 06, 2024 902

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.

Read more
How to change the connection string in App.config dynamically in C#
By Tan Lee Published on Jul 16, 2024 36.17K

To change the ConnectionString at runtime in a C# Windows Forms application using App.config, you typically follow these steps.

Read more
How to Create a custom Message Box in C#
By Tan Lee Published on Jul 16, 2024 57.24K

To customize a message box in C#, you can use the built-in MessageBox class or create a custom dialog using a Form.

Read more
How to retrieve the Executable Path in C#
By Tan Lee Published on Jul 03, 2024 3.59K

In C#, you can retrieve the executable path of the current application using the System.Reflection namespace.

Read more
How to Get all Forms and Open Form with Form Name in C#
By Tan Lee Published on Jul 27, 2017 12.85K

In C#, you can dynamically open or call a form by its name at runtime using reflection or by managing a collection of form names and their associated instances.

Read more
Connection string password with special characters in C#
By Tan Lee Published on Jun 21, 2024 2.56K

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.

Read more
How to scan IP address in a network using C#
By Tan Lee Published on May 28, 2024 21.57K

To scan a network for IP addresses in a C# Windows Forms Application, you typically need to send ICMP Echo requests (ping) to each IP address in the network range you want to scan.

Read more
How to Minimize application to system tray in C#
By Tan Lee Published on May 28, 2024 17.01K

Minimizing an application to the system tray in a C# Windows Forms application involves a few steps.

Read more
Async/Await with a Func delegate in C#
By Tan Lee Published on Jan 21, 2025 470

To make a Func delegate awaitable, you need to return a Task from the delegate.

Read more
How to use named tuples in C#
By Tan Lee Published on Mar 05, 2025 164

Tuples allow you to store multiple values together, which can be useful for passing around related data.

Read more
How to deconstruct tuples in C#
By Tan Lee Published on Mar 05, 2025 148

Deconstructing a tuple allows you to assign its values to multiple variables simultaneously using the deconstruction assignment syntax.

Read more
How to Read a text file line by line in C#
By Tan Lee Published on Mar 05, 2025 204

There are a couple of ways to read a text file line by line:

Read more
How to convert hex string to byte array in C#
By Tan Lee Published on Mar 04, 2025 230

You can convert a hex string to a byte array in C# using a lookup table and bitwise operations for efficiency.

Read more
Async SSE endpoint in ASP.NET Core
By Tan Lee Published on Mar 04, 2025 179

Server-Sent Events (SSE) allow a client to receive real-time updates from the server. Unlike WebSockets, SSE is a simpler alternative that works over HTTP and is ideal for one-way communication, such as notifications.

Read more
Update records with Dapper in C#
By Tan Lee Published on Jan 18, 2025 659

You can update records in a database using Dapper by leveraging the Execute() method along with an UPDATE statement.

Read more
How to group by multiple columns using LINQ
By Tan Lee Published on Dec 10, 2024 372

In LINQ, you can group by multiple columns using the group by clause in combination with anonymous types.

Read more
How to Update Progress Bar from Async Task in C#
By Tan Lee Published on Jun 20, 2024 36.54K

Using IProgress to update a ProgressBar from an asynchronous Task in a C# Windows Forms Application involves a few steps to properly handle the progress reporting and UI updates.

Read more
How to set json serializer settings in ASP.NET Core
By Tan Lee Published on Dec 27, 2024 577

In ASP.NET Core, you can configure JSON serializer settings for your application in a few different ways, typically through the Startup.cs or Program.cs file.

Read more
Serialize a tuple to JSON in C#
By Tan Lee Published on Feb 05, 2025 606

When you serialize a tuple to JSON, the underlying ValueTuple field names, Item1 and Item2, are used. This is true even if you are using a named tuple. The field names you specify in the tuple declaration won't be reflected in the JSON.

Read more
What does 'use strict;' means in Javascript
By Tan Lee Published on Feb 27, 2025 156

"Use strict;" is a directive in JavaScript that enforces stricter parsing and error handling on the code. When you apply strict mode, the interpreter enforces stricter rules, catching common coding mistakes and preventing certain problematic or error-prone syntax.

Read more
How to Use Conditional Middleware in ASP.NET Core
By Tan Lee Published on Feb 26, 2025 243

ASP.NET Core is a powerful, cross-platform framework designed by Microsoft for building high-performance web applications. It is lightweight and modular, allowing developers to configure middleware components that define how HTTP requests and responses are processed.

Read more
How to use the FromServices attribute in ASP.NET Core
By Tan Lee Published on Feb 26, 2025 158

ASP.NET Core has built-in support for dependency injection, allowing components to be injected at runtime. This makes your code more flexible, testable, and maintainable. Dependency injection can be performed in three ways: constructor injection, setter injection, and interface injection.

Read more
How to Implement authorization for Swagger in ASP.NET Core
By Tan Lee Published on Feb 26, 2025 504

When developing .NET applications, generating API documentation is often a necessary step. One of the most commonly used tools for this purpose is Swagger.

Read more
How to round up in C#
By Tan Lee Published on Nov 05, 2024 820

In C#, rounding is typically done using the Math.Round() method.

Read more
How to use Error Provider in C#
By Tan Lee Published on Jun 15, 2024 20.07K

In C# Windows Forms, the ErrorProvider component is used to provide visual indications of errors or warnings associated with user input controls, such as textboxes or comboboxes.

Read more
Creating Dynamic LINQ Queries in C# with Predicate Builder
By Tan Lee Published on Feb 22, 2025 158

In C#, one of the most powerful techniques for building dynamic LINQ queries is using the Predicate Builder.

Read more
Repository Pattern in .NET Core
By Tan Lee Published on Feb 21, 2025 370

Effective code organization is crucial when developing modern software, especially as the application structure becomes more intricate. One of the most effective design patterns to manage this complexity is the Repository Pattern.

Read more
How to Implement Mediator Pattern in .NET
By Tan Lee Published on Feb 21, 2025 192

In complex applications, objects often need to communicate with one another. While this may be simple in smaller applications with only a few components, the complexity increases as more components are added.

Read more
Basic Authentication in ASP.NET Core
By Tan Lee Published on Feb 17, 2025 202

Authentication and Authorization are critical aspects of securing any web application. ASP.NET Core Web API offers various methods to handle these tasks, with Basic Authentication being one of the simpler and widely used methods.

Read more