Created
May 23, 2018 06:27
-
-
Save Ibro/008aa78453cdd3f7e8492d206126dc57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
span.CopyTo(destination); | |
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("Destination Span:"); | |
foreach (var i in destination) | |
{ | |
Console.WriteLine(i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment