Convert Byte Array to File in C#
Oftentimes, we find ourselves with a chunk of data in a byte array that needs to be stored in a file. This is usually for the sake of storage or for further processing. Let's consider a few different ways to convert a byte array to a file. To...
Code Maze Weekly #114
Issue #114 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Classes, Structures, and Records, Oh My! [dotnettips.wordpress.com] Do you know the main difference between Class and Structure? Do you know when to use Records? David...
How to Add Parameters to a String in C#
In this article, we are going to learn how to add parameters to a string in C# in a few different ways. Let's start Using String.Format() Method Firstly, we can...
Array Slicing in C#
In this article, we are going to talk about array slicing in C#. We are going to explore different ways to slice an array in C# with some examples. Let's start....
Custom Attributes in .NET
Custom attributes in .NET (Core) are a helpful mechanism to attach additional information to classes, structs, and even their members. In this article, we're going to explain how to create, access, and get the information from custom attributes in .NET through some...
Introduction to Unit Testing With NUnit in C#
In this article, we are going to learn about unit testing with NUnit in C# through examples. Testing is one of the essential parts of the software development cycle, and there are many different test types. We'll concentrate our attention on programmatic tests, such...
How to Convert String to Int in C#
In this article, we are going to talk about how to convert string to int in C#. Int is an alias of Int32, and defines an integer number in range from -2,147,483,648 to +2,147,483,647. Setting a value of an int variable that is out of this range, will produce a "System...
Bubble Sort In C#
Sorting arrays is quite a common problem in programming. The bubble sort algorithm is simple to implement as it involves comparing adjacent elements and swapping them when they are in the wrong order. We are going to learn how Bubble Sort in C# works. [sc...
Code Maze Weekly #113
Issue #113 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Global usings in C# 10 [gunnarpeipman.com] Global using is one of the newest additions in C#. Gunnar Peipman explores this feature and shows us how it helps us. Step-up...
Different Ways to Iterate Through a Dictionary in C#
Dictionary allows us to store items in a collection using key-value pairs. It is included in the System.Collection.Generic namespace. In this article, we are going to learn how to iterate through a Dictionary in different ways. To download the...
Difference Between Task.Run and Task.Factory.StartNew
In this post, we are going to talk about the difference between Task.Run and Task.Factory.StartNew. If we ever engage in a discussion about task-based...
Minimal APIs in .NET 6
In this article, we are going to explain the core idea and basic concepts of the minimal APIs in .NET 6. But if we try to explain it in one sentence, it will be that it is an API without the need for a controller. Other than a theoretical explanation, we are going to...
DateTime Format In C#
In this article, we are going to learn how to work with DateTime format strings in C#. We can use format specifiers in C# to get string representations of DateTime values or to define the input string in a parse operation. The DateTime and DateTimeOffset classes in C#...
Differences Between != And Is Not Operators in C#
In this article, we are going to explore the differences between != and Is Not operators in C#. Let's start. Inequality != Operator Before we start talking...
Code Maze Weekly #112
Issue #112 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Implementing an API Gateway in ASP.NET Core with Ocelot [dotnetthoughts.net] How to build an API Gateway in ASP.NET Core with Ocelot by Anuraj Parameswaran. Testing...
Debugging C# in Visual Studio
The code we write doesn't always work the way we want it to. It could be due to a syntactical error or a logical one. While the compiler generally points to the syntax-related errors and helps us fix them, logical errors aren't that straightforward. This is when we...
Using RestSharp To Consume APIs in C#
In this article, we’re going to learn about using RestSharp in a .NET project. RestSharp is an open-source HTTP Client library that we can use to consume APIs easily. RestSharp features automatic serialization and deserialization, request and response type...
Rate Limiting in ASP.NET Core Web API (.NET 6)
In this article, we're going to talk about Rate Limiting in ASP.NET Core and explore some ways of implementing it. Let's dive into it. What Is Rate Limiting?...
Params Keyword in C#
In this article, we'll have a look at the params keyword in C#. We'll discuss the use cases and best practices. Let's dive in! What Is the 'Params' Keyword?...