Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created May 23, 2018 06:42
Show Gist options
  • Save Ibro/30b8b83ee12685a9d0259a1a6860184d to your computer and use it in GitHub Desktop.
Save Ibro/30b8b83ee12685a9d0259a1a6860184d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace SpanOfT_Dev
{
public class Program
{
private static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5 };
Span<int> span = arr.AsSpan();
var destination = new Span<int>(new int[arr.Length]);
var newArray = span.ToArray();
span.Clear();
Console.WriteLine("Array:");
foreach (var i in arr)
{
Console.WriteLine(i);
}
Console.WriteLine("Span:");
foreach (var i in span)
{
Console.WriteLine(i);
}
Console.WriteLine("New Array:");
foreach (var i in newArray)
{
Console.WriteLine(i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment