How to Get Formatted JSON in .Net Using C#
This article will examine how we can get a formatted JSON representation of our C# objects using two popular libraries – Json.NET and System.Text.Json.
PostgreSQL in C# .NET with Npgsql, Dapper, and Entity Framework: The Complete Guide
We’ll talk today about combining Postgres with my favorite language and runtime: C# and .NET. Just because Postgres isn’t a first-party Microsoft database, like SQL Server, doesn’t mean you don’t have full support for it in C#. You absolutely do, and in this article, you’ll see modern ways to do just that. You’ll see how to interact between Postgres and C# using the standard data provider library Npgsql, use it with Dapper, and even with Entity Framework. We’ll go over the basic operations like creating a table, inserting rows, deleting, and updating records using all of these frameworks.
ConcurrentDictionary in C# - Detailed Guide
We’ve already written about a regular Dictionary in C#. We’ve also explored the basics of ConcurrentDictionary as one of many Concurrent Collections in C#. In this article, we will go into more detail and explore the use cases in which ConcurrentDictionary can be useful to us.
Encrypting and Decrypting a String in C#
In this article, we will learn how encrypting and decrypting a string is done using C# and the Cryptography package that comes included with .NET.
Generic Attributes in C#
In this article, we are going to learn how generic attributes help us implement better custom attributes through a practical example.
How to Iterate Over JSON Objects in C#
Manipulating JSON objects is a common operation in applications. In this article, we will look at different ways of iterating over JSON objects in C#.
ConcurrentBag in C#
In C#, there are many classes that we can use to represent a group of objects that we may manipulate concurrently using multiple threads. One such class is the ConcurrentBag
Understanding Task and ValueTask in C#
If we want to optimize our code and improve the performance of our app, there is no one go-to solution. Instead, we analyze our code and try to find where to improve. Understanding Task
IEnumerable in C#
In this article, we are going to learn about IEnumerable in C#. IEnumerable acts as an abstraction over a collection and allows us to iterate over it without knowing the actual type of the collection.
Introducing C# 11: Required properties
C# 11 improves the initialization of objects and struct. Marking one or more properties as mandatory on initialization is now possible and will help you not to forget to initialize your properties correctly. In this post I will show you how it works with the object initializer syntax and the object instantiation with a constructor.
Introducing C#11: Raw string literals
C# 11 brings new syntax for writing plain text. Instead of relying on string interpolation with the character $ and the verbatim with @ character for writting on several lines, C# 11 allows using three double quotes. There is no need to double the quotes in the text to escape a double quote anymore. In this post, I will show you a simple example of it!
Floating-Point Types in C# - Double vs Float vs Decimal
In this article, we are going to cover floating-point types in C#. Our focus will be mainly on Double, Float and Decimal data types. We have covered the basic data types extensively, and you can check out this article if you feel the need to brush up on the basics.
C# String Interpolation
Very early in the history of programming, we’ve seen the need to use text on a machine that works with numbers. Over many decades we devised many different ways to construct and analyze text for better understanding by both humans and machines. String interpolation, in the way that C# offers it, is the most elegant and readable way to construct text messages we’ve seen so far.
How to Check if a String Ends With a Number in C#
Checking if a string ends with a number in C# is a very common operation. In this article, we are going to show various ways in which we can do this.
SortedSet in C#
A SortedSet in C# is a data structure that allows us to store and access elements in sorted order. In this article, we are going to explore how to create and use the SortedSet class in C#. We are also going to look at some of the benefits and drawbacks of using this data structure. Finally, the article concludes with tips on taking advantage of the C# SortedSet in our applications.
Welcome to C# 11
I am excited to announce that C# 11 is out! As always, C# opens some entirely new fronts, even while advancing several themes that have been in motion over past releases. There are many features and many details, which are beautifully covered under What’s new in C# 11 on our docs pages. What follows here is an appetizer of some of the highlights – small and big.
How to Use HTML Agility Pack in C#
In this article, we’re going to learn how to use HTML Agility Pack in C# and review some examples of its most important features.
Tasks vs Threads in C#
In this article, we are going to look at the main differences between Tasks and Threads. They are both used for concurrent programming, but Tasks were later introduced with .NET Framework 4.
Concurrent Collections in C#
Concurrent Collections in C# are a set of collections designed for synchronized multi-thread access. We can find concurrent collections under the System.Collections.Concurrent namespace. Nowadays, where it is getting increasingly important and accessible to work in a multi-threaded environment, concurrent collections are essential. .NET provides a set of concurrent collections. In this article, we will try to understand what concurrent collections are, the collections that have thread-safe variants, and the constraints of concurrent collections.
HashSet in C#
In this article, we are going to take a look at the HashSet class in C#. We will discuss how to use it and its key features. Also, we are going to see some examples of how to use it in practice. Finally, we’ll compare it to other data structures available in C#.