title: Does LINQ Enumerable query return copy or reference?
body: <p>I want to replicate the <code>Skip</code> and <code>Take</code> from C# in C++ in order to create slices. Something like:</p>
  
  <pre><code>std::vector&lt;int&gt; numbers = { 59, 82, 70, 56, 92, 98, 85 };
  
  auto slice = grades.skip(3).take(2); // {56, 92}
  </code></pre>
  
  <p>After checking how slices work in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice" rel="nofollow noreferrer">JS</a> and <a href="https://golangbot.com/arrays-and-slices/" rel="nofollow noreferrer">Golang</a>, I basically understand that they preferred shadow copy over deep copy. I understand the trade off between allocating new memory but having independent data and having related data by copying only the reference.</p>
  
  <p>Now, I also checked <a href="https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.skip?view=netframework-4.8#System_Linq_Enumerable_Skip__1_System_Collections_Generic_IEnumerable___0__System_Int32_" rel="nofollow noreferrer">Skip</a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.take?view=netframework-4.8#System_Linq_Enumerable_Take__1_System_Collections_Generic_IEnumerable___0__System_Int32_" rel="nofollow noreferrer">Take</a> but I can't find which one they use.</p>
  
  <p>In short, do they return some kind of Enumerator at the start and at the end? Or do they create an entirely new IEnumerable?</p>
  
  <h2>Edit</h2>
  
  <p>So, I didn't know we can access the source code (mentioned in the comments). And apparently it returns an iterator:</p>
  
  <pre><code>public static IEnumerable&lt;TSource&gt; Skip&lt;TSource&gt;(this IEnumerable&lt;TSource&gt; source, int count) {
     if (source == null) throw Error.ArgumentNull("source");
        return SkipIterator&lt;TSource&gt;(source, count);
     }
  }
  </code></pre>