Use ServiceCollection in Unit Tests with .NET
A popular unit test - and also a necessary test - is the correct registration of interfaces and their implementation with dependency injection. And a
A popular unit test - and also a necessary test - is the correct registration of interfaces and their implementation with dependency injection. And a
When working with ZIP files in .NET, there may be cases where the file is not stored on disk but comes directly as a Stream. This could happen if you
Working with compressed files is common in many applications, whether you're extracting data from an archive, installing software packages, or retrie
When working with .NET apps you may sometimes need to bundle multiple files into a single compressed archive for easier storage, transfer, or process
In C# (.NET 6 and above), there is now a very simple way to read out the CPU load with minimal overhead - i.e. without threads. The PerformanceCounte
Dealing with empty lists is an everyday situation in .NET. An empty list is often preferred to a null in order to control the logic. But how expensiv
We are currently in the preview phase of .NET 9, which releases in Nov 2024 - and if you want to test it extensively like I do, store the preview ver
Strings are one of the most commonly used types in .NET applications - and very often the source of inefficient code. For example, cleaning up a stri
Refit is an open-source library for .NET developers that simplifies the process of making HTTP API calls. It allows developers to define a set of int
Strong Name Signing is a mechanism in .NET development that ensures the integrity and authenticity of assemblies. It is based on a public-private key
YAML files are unfortunately part of everyday life for all developers these days; and although they are very error-prone and almost impossible to edi
TLDR; You can see the full sample in my GitHub repository BEN ABT Samples - ASP.NET Core Form protection with Cloudflare's Turnstile Turnstile is a
It's now been a few months since the GDPR-drama and data-harvesting around Moq (Stop using Moq as a guinea pig to get feedback on and develop Sponsor
.NET event counters are a relatively new API for collecting metrics from .NET applications. They are part of the EventSource and EventCounter namespa
By default, Azure Application Insights comes with necessary and important telemetry capabilities to monitor the basic functions of an application and
The Azure Communication Service is a fairly new but already popular service for sending emails at scale. In this article, I would like to show you ho
The Azure Communication Service is a fairly new but already popular service for sending emails at scale. In this article, I would like to show you ho
One of the last blog posts (Text and EMail Templates with Handlebars.NET) was generally about HandleBars.NET - a very popular template engine. This p
API models are one of the elements where I personally see the most naming errors - which have a massive impact on the architect and cause subsequent
In many code bases there are Services and Providers - and often they do the same thing structurally; but what is the idea of a Service- and Provider-
Database entities are the objects that represent the tables in your database. They are the objects that you use to read and write the database. Namin
Often seen, often used incorrectly: DTOs. Data Transfer Objects. In principle, DTO is an umbrella term, a design pattern that is used to transfer dat
A frequent requirement in apps is the conversion of templates, e.g. for sending e-mails, for PDF templates or other text modules. There are many diff
QR codes are a simple and very popular way of exchanging data and information - even in .NET. They have become part of everyday life. Unfortunately,
There are various ways to deploy an application, but Zip deployment is the variant that is recommended the most - regardless of whether you are using
With .NET 8, the System.ComponentModel.DataAnnotations Namespace has been revised and some new attributes have been added that have been requested by
A database entity represents an identifiable entry, often also things from the real world, which are to be stored and managed in the database. The pu
In C#, optional arguments are parameters in a method that have default values specified in the method's declaration. This means that when you call th
As has been the case for many releases, the .NET 8 team is spending a lot of development effort to improve the .NET Runtime in terms of performance.
Some APIs do not follow standards, ignore ISO8601 and return UnixTime. This is not nice, but can be easily fixed with a custom converter for System.T
A little more than three months ago, Microsoft integrated a new functionality into Visual Studio 2022: Build Acceleration. This mechanism, which can
I often see snippets in EF Core code reviews such as the following: dbContext.Users.Where( user => user.Id == id ); The query filter user => u
Unit testing is a type of software testing that is performed on the smallest unit of a software application, called a "unit". A unit can be
In many software architectures the problem exists that there are methods, which are specified a multiplicity of type-same parameters, whose meaning i
September last year, Microsoft announced that a large number of backend services would be migrated to .NET 6. This, they said, was an enterprise-wide
Structs have their advantages in .NET: they are especially efficient in the runtime if used correctly. But if you use structs with an interface, the
Both C# is null and == null are used to check if a variable or object is null, but they work slightly differently. is null checks if the variable or
Symbolic Links (often abbreviated as symlinks) are a type of file or folder shortcut in Windows that reference another file or folder in the file sys
The isolated mode of Azure Functions with .NET allows for greater control over the runtime environment and dependencies of the function. In this mode
Statische Methoden in C# sind Methoden, die auf eine Klasse und nicht auf eine bestimmte Instanz einer Klasse angewendet werden. Sie können aufgerufe
Expressions are now an absolute part of a developer's everyday life in .NET thanks to Linq. However, due to their nature, expressions are not one of
.NET has two principal ways for handling times: DateTime and DateTimeOffset. The big deficit of DateTime, which was also recognized early in .NET 1.0
Microsoft has announced in an impressive blog post on the .NET DevBlogs that they have started an enterprise-wide migration to migrate backend servic
Beginning with C# 3, variables that are declared at method scope can have an implicit "type" var. An implicitly typed local variable is st
Requirements You must have created an IoT Hub in Azure. You must have created a device in your created Azure IoT Hub. You need the connection string
In .NET, there is a very fast and easy way to pump a variety of entities into an SQL database: SqlBulkCopy public void BulkInsert<TEntity>(stri
This pretty simply snippet exports your Image into a byte-array. public static byte[] ToByteArray(this System.Drawing.Image image) { using(Memory
The most current and currently recommended way to download .NET Framework, .NET Standard or .NET Core files from the Internet is the HttpClient class
Unter anderem durch die Aktivität im myCSharp.de-Forum ist mir aufgefallen, dass viele Entwickler doch Probleme mit der Konfiguration von WCF-Dienste
Die Zeit am Flughafen möchte ich dazu nutzen einer meiner Anfragen per E-Mail zu beantworten. Hallo Benjamin, wie testest du Quellcode, der mit inte
Dieser Codeschnippsel soll exemplarisch zeigen, wie man in C# eigene Events definiert. Als Beispiel dient hier die Überwachung von E-Mails in der Kon
Oft werden Warteschlangen benötigt, um Aufgaben zu Verwalten oder durch etwaige Parallelität die Performance zu Steigern. Mit .NET 4.0 hat Microsoft
Ich wurde schon öfter im Zusammenhang gefragt (insbesondere im Forum myCSharp.de), wie ich sogenannte Magic Strings vermeide. Was ist ein Magic Strin