How to Get the HTML Content of a Web Page as a String in .NET
In this article, we will look into a comprehensive guide on how to get the HTML content of a web page as a string and how to parse the content retrieved. First things first, we'll learn how to retrieve HTML content as a string from the web using tools like HttpClient,...
How to Use Entity Framework Core Migrations in Production
In this article, we will discuss the different approaches to migrating a production database when using Entity Framework (EF) Core code-first migrations. types. We aim to understand how to convert ReadOnlyMemory to a byte array, specifically using the MemoryMarshal.AsBytes() method. We also explore scenarios where this...
Code Maze Weekly #206
Issue #206 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks C# 12: Collection Expressions [www.thomasclaudiushuber.com] C# 12 has introduced a new and simpler way to initialize collections. If you want to stay...
How to Benchmark a Method’s Performance Across Different .NET Versions
As .NET developers, we often benchmark the performance of our methods using a single .NET version. However, we can also benchmark a method's performance across different .NET versions. Such benchmarks can come in handy when we want to upgrade our codebase to a newer...
How to Convert IAsyncEnumerable to List
In this article, we will learn how to convert IAsyncEnumerable to a List in C#. We'll talk about some practical reasons for this conversion and explore the common method for achieving it. [sc name="github"...
How to Convert String to Char in C#
In C# development, working with strings and characters is essential. This article explores how to convert a string to a char array. It also extends into converting arrays of strings to arrays of characters. [sc name="github"...
Using Memory For Efficient Memory Management in C#
Effective memory management is a crucial aspect of programming languages, especially when performance and efficiency are paramount. In C#, developers have access to a powerful API, Memory<T>, enabling them to work flexibly and efficiently with memory. In this...
Execute the SELECT WHERE NOT EXIST SQL Query Using LINQ
In database querying, the SELECT WHERE NOT EXISTS clause plays a pivotal role in retrieving data based on the absence of certain conditions. This is particularly useful when filtering records that do not have corresponding entries in another table. In this article, we...
Different Methods for Computing the Size of a Directory in C#
In this article, we look into various ways to calculate the size of a directory. Applications dealing with file management or storage inevitably need to know how much space a directory takes up. Calculating the directory size helps with disk space management as we can...
How to Resolve IOptions Instance Inside Program Class in C#
In this article, we’ll look at resolving the IOptions instance in the Program class, ensuring we avoid common pitfalls and learn some best practices. As software developers, we frequently encounter the challenge of managing application configurations. However, to make...
Why Should We Avoid Using Await in a Loop in C#
It is essential to carefully consider when to use the await keyword in a for or for-each loop to prevent inefficiency and performance issues in software development. In this article, we will explore scenarios where using the await keyword in a loop is appropriate and...
Difference Between await and Task.Wait in C#
In this article, we will discuss the differences between await and Task.Wait() in C# and .NET. We will start by looking into concepts like Blocking Code and Asynchronous Programming. We will see how we can use await and Task.Wait() in our code and their effects on our...
Automatic Registration of Minimal API Endpoints in .NET
In this article, we will explore how we can improve our Minimal API endpoints in .NET with automatic registration. Let's dive...
Comparing Performance of the switch and if-else Statements in C#
In this article, we delve into the performance nuances of switch and if-else statements in C#, two pivotal control flow mechanisms. Through a comparative analysis, we'll explore how each statement impacts application performance under various conditions, supported by...
How to Use StringPool to Reduce String Allocations in C#
In software development, effective memory management plays a pivotal role, acting as a secret sauce to enhance our application's performance. When working with C# code, managing strings, a common task, significantly impacts our program's memory usage. Because .NET...
Fastest Way to Generate a Random Boolean in C#
Generating random boolean values is a common challenge in programming tasks, especially when randomness is required for gaming or testing data. With that said, let's explore some methods to generate boolean values as quickly as possible. [sc name="github"...