
C# 9 and .NET 5 – Modern Cross-Platform Development
By :

One of Microsoft's goals with .NET Core 2.1 was to improve performance and resource usage. A key .NET feature that enables this is the Span<T>
type.
More Information: You can read the official documentation for Span<T>
at the following link: https://docs.microsoft.com/en-us/dotnet/api/system.span-1
When manipulating collections of objects, you will often create new collections from existing ones so that you can pass parts of a collection. This is not efficient because duplicate objects are created in memory.
If you need to work with a subset of a collection, instead of replicating the subset into a new collection, use a span because it is like a window into a subset of the original collection. This is more efficient in terms of memory usage and improves performance.
Before we look at spans in more detail, we need to understand some related objects: indexes...