...

/

Working with Spans, Indexes, and Ranges

Working with Spans, Indexes, and Ranges

Learn about the span, index, and range, making memory usage more efficient and improving performance.

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.

Using memory efficiently using spans

When manipulating arrays, we often create new copies of subsets of existing ones so that we can process just the subset. This is not efficient because duplicate objects must be created in memory. If we need to work with a subset of an array, use a span because it is like a window into the original array.

Press + to interact
Window of Array and Span
Window of Array and Span

This is more ...